mail-accounts/migrations/20231008100114_lists_recipients.sql

13 lines
323 B
MySQL
Raw Normal View History

-- 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)
);