diff --git a/sql/branch.sql b/sql/branch.sql new file mode 100644 index 0000000000..edff038b0a --- /dev/null +++ b/sql/branch.sql @@ -0,0 +1,9 @@ +ALTER TABLE emails DROP CONSTRAINT emails_participant_fkey; + +ALTER TABLE emails ALTER COLUMN participant TYPE bigint USING participant::bigint; + +CREATE SEQUENCE emails_participant_seq; +ALTER TABLE emails ALTER COLUMN participant SET DEFAULT nextval('emails_participant_seq'); +ALTER SEQUENCE emails_participant_seq OWNED BY emails.participant; + +ALTER TABLE emails ADD FOREIGN KEY (participant) REFERENCES participants(id) ON UPDATE CASCADE ON DELETE RESTRICT;