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

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

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

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

ALTER TABLE switch ADD CONSTRAINT switch_greeting_constraint  FOREIGN KEY (greeting) REFERENCES soundfile(id);
ALTER TABLE switch ADD CONSTRAINT switch_phoneline1_constraint  FOREIGN KEY (phoneline1) REFERENCES phoneline (id);
ALTER TABLE switch ADD CONSTRAINT switch_phoneline2_constraint  FOREIGN KEY (phoneline2) REFERENCES phoneline (id);
ALTER TABLE switch ADD CONSTRAINT switch_phoneline3_constraint  FOREIGN KEY (phoneline3) REFERENCES phoneline (id);

