BEGIN;
alter table phone add column dndkeyfunc varchar(6);
update phone set dndkeyfunc = 'pbx' where dndkeyfunc IS NULL;
alter table phone alter column dndkeyfunc set NOT NULL;
alter table phone alter column dndkeyfunc set default 'pbx';
alter table phone add CONSTRAINT phone_dndkeyfunc_check CHECK (dndkeyfunc IN ('pbx', 'phone'));

alter table phonetype add column dndkeyfunc varchar(6);
update phonetype set dndkeyfunc = 'pbx' where dndkeyfunc IS NULL;
alter table phonetype alter column dndkeyfunc set NOT NULL;
alter table phonetype alter column dndkeyfunc set default 'pbx';
alter table phonetype add CONSTRAINT phone_dndkeyfunc_check CHECK (dndkeyfunc IN ('pbx', 'phone'));

alter table phonetypephone add column dndkeyfunc varchar(6);
update phonetypephone set dndkeyfunc = 'pbx' where dndkeyfunc IS NULL;
alter table phonetypephone alter column dndkeyfunc set NOT NULL;
alter table phonetypephone alter column dndkeyfunc set default 'pbx';
alter table phonetypephone add CONSTRAINT phone_dndkeyfunc_check CHECK (dndkeyfunc IN ('pbx', 'phone'));

alter table phonetypecontactphone add column dndkeyfunc varchar(6);
update phonetypecontactphone set dndkeyfunc = 'pbx' where dndkeyfunc IS NULL;
alter table phonetypecontactphone alter column dndkeyfunc set NOT NULL;
alter table phonetypecontactphone alter column dndkeyfunc set default 'pbx';
alter table phonetypecontactphone add CONSTRAINT phone_dndkeyfunc_check CHECK (dndkeyfunc IN ('pbx', 'phone'));
COMMIT;
