-- Add migration script here

ALTER TABLE emails
	ADD CONSTRAINT email_type_unique UNIQUE (mail, type);

CREATE TABLE list_recipients (
	list TEXT NOT NULL,
	type mail_type NOT NULL CHECK (type = 'list'),
	recipient TEXT NOT NULL,
	PRIMARY KEY (list, recipient),
	FOREIGN KEY (list, type) REFERENCES emails (mail, type)
);
