alter table inbound add column switch integer;
update inbound set switch = '1' where switch IS NULL;
alter table inbound alter column switch set default '1';
alter table inbound alter column switch set not null;

alter table inbound add column sw_greeting integer;
update inbound set sw_greeting = '1' where sw_greeting IS NULL;
alter table inbound alter column sw_greeting set default '1';
alter table inbound alter column sw_greeting set not null;

alter table inbound add column sw_phoneline1 integer;
update inbound set sw_phoneline1 = '1' where sw_phoneline1 IS NULL;
alter table inbound alter column sw_phoneline1 set default '1';
alter table inbound alter column sw_phoneline1 set not null;

alter table inbound add column sw_phoneline2 integer;
update inbound set sw_phoneline2 = '1' where sw_phoneline2 IS NULL;
alter table inbound alter column sw_phoneline2 set default '1';
alter table inbound alter column sw_phoneline2 set not null;

alter table inbound add column sw_phoneline3 integer;
update inbound set sw_phoneline3 = '1' where sw_phoneline3 IS NULL;
alter table inbound alter column sw_phoneline3 set default '1';
alter table inbound alter column sw_phoneline3 set not null;

ALTER TABLE inbound ADD CONSTRAINT inbound_switch_constraint  FOREIGN KEY (switch) REFERENCES switch(id);
ALTER TABLE inbound ADD CONSTRAINT inbound_sw_greeting_constraint  FOREIGN KEY (sw_greeting) REFERENCES soundfile(id);
ALTER TABLE inbound ADD CONSTRAINT inbound_sw_phoneline1_constraint  FOREIGN KEY (sw_phoneline1) REFERENCES phoneline (id);
ALTER TABLE inbound ADD CONSTRAINT inbound_sw_phoneline2_constraint  FOREIGN KEY (sw_phoneline2) REFERENCES phoneline (id);
ALTER TABLE inbound ADD CONSTRAINT inbound_sw_phoneline3_constraint  FOREIGN KEY (sw_phoneline3) REFERENCES phoneline (id);

