summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2022-05-05 19:37:56 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2022-05-05 19:37:56 +0200
commit5340096101e67892ca3229bd8a235847c6e7384b (patch)
tree33d7f89f883557bb47ea88cba6ed099516f3e473
parenteb3e3132d608b7b8444347d0b7e1a8dd225af20a (diff)
downloadnixos-5340096101e67892ca3229bd8a235847c6e7384b.tar
nixos-5340096101e67892ca3229bd8a235847c6e7384b.tar.gz
nixos-5340096101e67892ca3229bd8a235847c6e7384b.tar.bz2
nixos-5340096101e67892ca3229bd8a235847c6e7384b.tar.xz
nixos-5340096101e67892ca3229bd8a235847c6e7384b.zip
...
-rw-r--r--hosts/surtr/postgresql.nix6
1 files changed, 3 insertions, 3 deletions
diff --git a/hosts/surtr/postgresql.nix b/hosts/surtr/postgresql.nix
index d8f66fcc..0529a0f2 100644
--- a/hosts/surtr/postgresql.nix
+++ b/hosts/surtr/postgresql.nix
@@ -33,8 +33,8 @@ in {
33 CREATE TABLE mailbox ( 33 CREATE TABLE mailbox (
34 id uuid PRIMARY KEY NOT NULL DEFAULT gen_random_uuid(), 34 id uuid PRIMARY KEY NOT NULL DEFAULT gen_random_uuid(),
35 mailbox text NOT NULL CONSTRAINT mailbox_non_empty CHECK (mailbox <> '''), 35 mailbox text NOT NULL CONSTRAINT mailbox_non_empty CHECK (mailbox <> '''),
36 quota_bytes bigint CONSTRAINT quota_bytes_positive CHECK (CASE WHEN quota_bytes IS NOT NULL THEN quota_bytes > 0 ELSE true), 36 quota_bytes bigint CONSTRAINT quota_bytes_positive CHECK (CASE WHEN quota_bytes IS NOT NULL THEN quota_bytes > 0 ELSE true END),
37 quota_rule text GENERATED ALWAYS AS (CASE WHEN quota_bytes IS NULL THEN '*:ignore' ELSE '*:bytes=' || quota_bytes) STORED 37 quota_rule text GENERATED ALWAYS AS (CASE WHEN quota_bytes IS NULL THEN '*:ignore' ELSE '*:bytes=' || quota_bytes END) STORED
38 ) 38 )
39 CREATE TABLE mailbox_mapping ( 39 CREATE TABLE mailbox_mapping (
40 id uuid PRIMARY KEY NOT NULL DEFAULT gen_random_uuid(), 40 id uuid PRIMARY KEY NOT NULL DEFAULT gen_random_uuid(),
@@ -46,7 +46,7 @@ in {
46 CREATE UNIQUE INDEX domain_unique ON virtual_mailbox_mapping (domain) WHERE local IS NULL; 46 CREATE UNIQUE INDEX domain_unique ON virtual_mailbox_mapping (domain) WHERE local IS NULL;
47 47
48 CREATE VIEW virtual_mailbox_domain (domain) AS SELECT DISTINCT domain FROM virtual_mailbox_mapping; 48 CREATE VIEW virtual_mailbox_domain (domain) AS SELECT DISTINCT domain FROM virtual_mailbox_mapping;
49 CREATE VIEW virtual_mailbox_mapping (mailbox, lookup) AS SELECT mailbox.mailbox as mailbox, (CASE WHEN local IS NULL THEN ''' ELSE local) || '@' || domain AS lookup FROM mailbox_mapping INNER JOIN mailbox on mailbox.id = mailbox_mapping.mailbox; 49 CREATE VIEW virtual_mailbox_mapping (mailbox, lookup) AS SELECT mailbox.mailbox as mailbox, (CASE WHEN local IS NULL THEN ''' ELSE local END) || '@' || domain AS lookup FROM mailbox_mapping INNER JOIN mailbox on mailbox.id = mailbox_mapping.mailbox;
50 COMMIT; 50 COMMIT;
51 ''} 51 ''}
52 ''; 52 '';