BEGIN;

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

ALTER TABLE contact ADD CONSTRAINT contact_role_constraint FOREIGN KEY (role) REFERENCES role (id);

COMMIT;
