summaryrefslogtreecommitdiff
path: root/hosts/surtr/postgresql.nix
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2022-05-06 00:10:16 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2022-05-06 00:10:16 +0200
commite23823d812de7df0eb1c3f8c9df63956158802c6 (patch)
tree55b23c29b1f268c048473d8b65caeea02d4547c8 /hosts/surtr/postgresql.nix
parentff566cb93a9b4ce63d5663328d99399da3a3ee5a (diff)
downloadnixos-e23823d812de7df0eb1c3f8c9df63956158802c6.tar
nixos-e23823d812de7df0eb1c3f8c9df63956158802c6.tar.gz
nixos-e23823d812de7df0eb1c3f8c9df63956158802c6.tar.bz2
nixos-e23823d812de7df0eb1c3f8c9df63956158802c6.tar.xz
nixos-e23823d812de7df0eb1c3f8c9df63956158802c6.zip
surtr: ...
Diffstat (limited to 'hosts/surtr/postgresql.nix')
-rw-r--r--hosts/surtr/postgresql.nix13
1 files changed, 13 insertions, 0 deletions
diff --git a/hosts/surtr/postgresql.nix b/hosts/surtr/postgresql.nix
index 28ccd8c4..0352c27f 100644
--- a/hosts/surtr/postgresql.nix
+++ b/hosts/surtr/postgresql.nix
@@ -60,10 +60,23 @@ in {
60 BEGIN; 60 BEGIN;
61 SELECT _v.register_patch('002-citext', ARRAY['000-base'], null); 61 SELECT _v.register_patch('002-citext', ARRAY['000-base'], null);
62 62
63 DROP VIEW virtual_mailbox_domain;
64 DROP VIEW virtual_mailbox_mapping;
65 DROP VIEW imap_user;
66 DROP VIWE lmtp_mapping;
67
63 CREATE EXTENSION citext; 68 CREATE EXTENSION citext;
69
64 ALTER TABLE mailbox ALTER mailbox TYPE citext; 70 ALTER TABLE mailbox ALTER mailbox TYPE citext;
65 ALTER TABLE mailbox_mapping ALTER local TYPE citext; 71 ALTER TABLE mailbox_mapping ALTER local TYPE citext;
66 ALTER TABLE mailbox_mapping ALTER domain TYPE citext; 72 ALTER TABLE mailbox_mapping ALTER domain TYPE citext;
73
74 CREATE VIEW mailbox_quote_rule (id, mailbox, quota_rule) AS SELECT id, mailbox, (CASE WHEN quota_bytes IS NULL THEN '*:ignore' ELSE '*:bytes=' || quota_bytes END) AS quota_rule FROM mailbox;
75
76 CREATE VIEW virtual_mailbox_domain (domain) AS SELECT DISTINCT domain FROM mailbox_mapping;
77 CREATE VIEW virtual_mailbox_mapping (lookup) AS SELECT (CASE WHEN local IS NULL THEN ''' ELSE local END) || '@' || domain AS lookup FROM mailbox_mapping;
78 CREATE VIEW imap_user ("user", quota_rule) AS SELECT mailbox AS "user", quota_rule FROM mailbox_quota_rule;
79 CREATE VIEW lmtp_mapping ("user", quota_rule, local, domain) AS SELECT mailbox_quota_rule.mailbox AS "user", quota_rule, local, domain FROM mailbox_quota_rule INNER JOIN mailbox_mapping ON mailbox_quota_rule.id = mailbox_mapping.mailbox;
67 COMMIT; 80 COMMIT;
68 ''} 81 ''}
69 ''; 82 '';