Use mailing lists instead of aliases for stalwart
This commit is contained in:
parent
56b71230e9
commit
f09444d832
6 changed files with 78 additions and 52 deletions
4
migrations/20231008093906_alias_table.sql
Normal file
4
migrations/20231008093906_alias_table.sql
Normal 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;
|
||||
7
migrations/20231008094925_lists.sql
Normal file
7
migrations/20231008094925_lists.sql
Normal 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;
|
||||
12
migrations/20231008100114_lists_recipients.sql
Normal file
12
migrations/20231008100114_lists_recipients.sql
Normal 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)
|
||||
);
|
||||
3
migrations/20231008101016_type_not_null.sql
Normal file
3
migrations/20231008101016_type_not_null.sql
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
-- Add migration script here
|
||||
ALTER TABLE emails
|
||||
ALTER COLUMN type SET NOT NULL;
|
||||
Loading…
Add table
Add a link
Reference in a new issue