From 2622b6833f8c79707672918441a033daaefb6533 Mon Sep 17 00:00:00 2001 From: mwiegand Date: Thu, 8 Jul 2021 02:06:20 +0200 Subject: [PATCH] wip --- bundles/mailserver/items.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bundles/mailserver/items.py b/bundles/mailserver/items.py index 14527b7..04b4e0c 100644 --- a/bundles/mailserver/items.py +++ b/bundles/mailserver/items.py @@ -20,12 +20,18 @@ setup = f""" CREATE TABLE users ( "id" BIGSERIAL PRIMARY KEY, - "name" varchar(255) NOT NULL, + "name" varchar(255) NULL, "domain_id" BIGSERIAL REFERENCES domains(id), "password" varchar(255) NULL, "redirect" varchar(255) DEFAULT NULL ); CREATE UNIQUE INDEX ON users ("name", "domain_id") WHERE "redirect" IS NULL; + ALTER TABLE users + ADD CONSTRAINT name_unless_redirect + CHECK (name IS NOT null OR redirect IS NOT null); + ALTER TABLE users + ADD CONSTRAINT no_password_for_redirects + CHECK (redirect IS null OR password IS null); -- OWNERSHIPS