summaryrefslogtreecommitdiff
path: root/hosts/surtr
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2022-05-05 18:16:08 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2022-05-05 18:16:08 +0200
commit845d0340201db81e6c605537ef27ed13f946d892 (patch)
tree73ba7d07c3f419f36b45a8721d4461340ffe5061 /hosts/surtr
parente9c1d4c91d770f20a06473209aaba5c48c1ec84a (diff)
downloadnixos-845d0340201db81e6c605537ef27ed13f946d892.tar
nixos-845d0340201db81e6c605537ef27ed13f946d892.tar.gz
nixos-845d0340201db81e6c605537ef27ed13f946d892.tar.bz2
nixos-845d0340201db81e6c605537ef27ed13f946d892.tar.xz
nixos-845d0340201db81e6c605537ef27ed13f946d892.zip
...
Diffstat (limited to 'hosts/surtr')
-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 '';