Use mailing lists instead of aliases for stalwart

This commit is contained in:
traxys 2023-10-08 13:06:12 +02:00
parent 56b71230e9
commit f09444d832
6 changed files with 78 additions and 52 deletions

View file

@ -0,0 +1,4 @@
-- Add migration script here
DROP TABLE alias_recipient;
DELETE FROM emails WHERE alias = true;
ALTER TABLE emails DROP COLUMN alias;

View file

@ -0,0 +1,7 @@
CREATE TYPE mail_type AS ENUM ('primary', 'alias', 'list');
ALTER TABLE emails
ADD COLUMN type mail_type DEFAULT 'primary';
ALTER TABLE emails
ALTER COLUMN type DROP DEFAULT;

View file

@ -0,0 +1,12 @@
-- 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)
);

View file

@ -0,0 +1,3 @@
-- Add migration script here
ALTER TABLE emails
ALTER COLUMN type SET NOT NULL;