From e9c1d4c91d770f20a06473209aaba5c48c1ec84a Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 5 May 2022 18:12:55 +0200 Subject: ... --- hosts/surtr/postgresql.nix | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/hosts/surtr/postgresql.nix b/hosts/surtr/postgresql.nix index 510437aa..ca56f60c 100644 --- a/hosts/surtr/postgresql.nix +++ b/hosts/surtr/postgresql.nix @@ -28,18 +28,16 @@ in { \i ${versioning + "/install.versioning.sql"} BEGIN; - select _v.register_patch('000-base', null, null); + SELECT _v.register_patch('000-base', null, null); - create table virtual_mailbox ( + CREATE TABLE virtual_mailbox ( id uuid PRIMARY KEY NOT NULL DEFAULT gen_random_uuid(), - local text, - CHECK (local IS DISTINCT FROM '''), - domain text NOT NULL, - CHECK (domain <> '''), - mailbox text NOT NULL, - CHECK (mailbox <> '''), - UNIQUE(COALESCE(local, '''), domain) + local text CONSTRAINT local_non_empty CHECK (local IS DISTINCT FROM '''), + domain text NOT NULL CONSTRAINT domain_non_empty CHECK (domain <> '''), + mailbox text NOT NULL CONSTRAINT mailbox_non_empty CHECK (mailbox <> '''), + CONSTRAINT local_domain_unique UNIQUE (local, domain) ); + CREATE UNIQUE INDEX domain_unique ON TABLE virtual_mailbox (domain) WHERE local IS NULL; COMMIT; ''} ''; -- cgit v1.2.3