From 5340096101e67892ca3229bd8a235847c6e7384b Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 5 May 2022 19:37:56 +0200 Subject: ... --- hosts/surtr/postgresql.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'hosts') 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 { CREATE TABLE mailbox ( id uuid PRIMARY KEY NOT NULL DEFAULT gen_random_uuid(), mailbox text NOT NULL CONSTRAINT mailbox_non_empty CHECK (mailbox <> '''), - quota_bytes bigint CONSTRAINT quota_bytes_positive CHECK (CASE WHEN quota_bytes IS NOT NULL THEN quota_bytes > 0 ELSE true), - quota_rule text GENERATED ALWAYS AS (CASE WHEN quota_bytes IS NULL THEN '*:ignore' ELSE '*:bytes=' || quota_bytes) STORED + quota_bytes bigint CONSTRAINT quota_bytes_positive CHECK (CASE WHEN quota_bytes IS NOT NULL THEN quota_bytes > 0 ELSE true END), + quota_rule text GENERATED ALWAYS AS (CASE WHEN quota_bytes IS NULL THEN '*:ignore' ELSE '*:bytes=' || quota_bytes END) STORED ) CREATE TABLE mailbox_mapping ( id uuid PRIMARY KEY NOT NULL DEFAULT gen_random_uuid(), @@ -46,7 +46,7 @@ in { CREATE UNIQUE INDEX domain_unique ON virtual_mailbox_mapping (domain) WHERE local IS NULL; CREATE VIEW virtual_mailbox_domain (domain) AS SELECT DISTINCT domain FROM virtual_mailbox_mapping; - 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; + 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; COMMIT; ''} ''; -- cgit v1.2.3