summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hosts/surtr/postgresql.nix7
1 files changed, 5 insertions, 2 deletions
diff --git a/hosts/surtr/postgresql.nix b/hosts/surtr/postgresql.nix
index ca56f60c..7b3b8c74 100644
--- a/hosts/surtr/postgresql.nix
+++ b/hosts/surtr/postgresql.nix
@@ -30,14 +30,17 @@ in {
30 BEGIN; 30 BEGIN;
31 SELECT _v.register_patch('000-base', null, null); 31 SELECT _v.register_patch('000-base', null, null);
32 32
33 CREATE TABLE virtual_mailbox ( 33 CREATE TABLE virtual_mailbox_mapping (
34 id uuid PRIMARY KEY NOT NULL DEFAULT gen_random_uuid(), 34 id uuid PRIMARY KEY NOT NULL DEFAULT gen_random_uuid(),
35 local text CONSTRAINT local_non_empty CHECK (local IS DISTINCT FROM '''), 35 local text CONSTRAINT local_non_empty CHECK (local IS DISTINCT FROM '''),
36 domain text NOT NULL CONSTRAINT domain_non_empty CHECK (domain <> '''), 36 domain text NOT NULL CONSTRAINT domain_non_empty CHECK (domain <> '''),
37 mailbox text NOT NULL CONSTRAINT mailbox_non_empty CHECK (mailbox <> '''), 37 mailbox text NOT NULL CONSTRAINT mailbox_non_empty CHECK (mailbox <> '''),
38 CONSTRAINT local_domain_unique UNIQUE (local, domain) 38 CONSTRAINT local_domain_unique UNIQUE (local, domain)
39 ); 39 );
40 CREATE UNIQUE INDEX domain_unique ON TABLE virtual_mailbox (domain) WHERE local IS NULL; 40 CREATE UNIQUE INDEX domain_unique ON virtual_mailbox_mapping (domain) WHERE local IS NULL;
41
42 CREATE VIEW virtual_mailbox_domain (domain) AS SELECT DISTINCT domain FROM virtual_mailbox_mapping;
43 CREATE VIEW virtual_mailbox (mailbox) AS SELECT DISTINCT mailbox FROM virtual_mailbox_mapping;
41 COMMIT; 44 COMMIT;
42 ''} 45 ''}
43 ''; 46 '';