Add database table for catchall destinations
Catch-all aliases are stored for a domain. Since there can be multiple
destinations per domain, this is done using a 1:n relation on the gid.
This commit extends the SQL schema definition and also provides appropriate
upgrade DDL.
--- a/pgsql/create_tables-dovecot-1.2.x.pgsql Sun Apr 08 19:05:25 2012 +0000
+++ b/pgsql/create_tables-dovecot-1.2.x.pgsql Mon Apr 09 17:45:02 2012 +0200
@@ -173,6 +173,14 @@
REFERENCES domain_data (gid)
);
+CREATE TABLE catchall (
+ gid bigint NOT NULL,
+ destination varchar(320) NOT NULL,
+ CONSTRAINT pkey_catchall PRIMARY KEY (gid, destination),
+ CONSTRAINT fkey_catchall_gid_domain_data FOREIGN KEY (gid)
+ REFERENCES domain_data (gid)
+);
+
CREATE OR REPLACE VIEW postfix_gid AS
SELECT gid, domainname
FROM domain_name;
--- a/pgsql/create_tables.pgsql Sun Apr 08 19:05:25 2012 +0000
+++ b/pgsql/create_tables.pgsql Mon Apr 09 17:45:02 2012 +0200
@@ -173,6 +173,14 @@
REFERENCES domain_data (gid)
);
+CREATE TABLE catchall (
+ gid bigint NOT NULL,
+ destination varchar(320) NOT NULL,
+ CONSTRAINT pkey_catchall PRIMARY KEY (gid, destination),
+ CONSTRAINT fkey_catchall_gid_domain_data FOREIGN KEY (gid)
+ REFERENCES domain_data (gid)
+);
+
CREATE OR REPLACE VIEW postfix_gid AS
SELECT gid, domainname
FROM domain_name;
--- a/pgsql/update_tables_0.5.x-0.6-dovecot-1.2.x.pgsql Sun Apr 08 19:05:25 2012 +0000
+++ b/pgsql/update_tables_0.5.x-0.6-dovecot-1.2.x.pgsql Mon Apr 09 17:45:02 2012 +0200
@@ -165,6 +165,18 @@
FOREIGN KEY (ssid) REFERENCES service_set (ssid);
-- ---
+-- Catchall
+-- ---
+
+CREATE TABLE catchall (
+ gid bigint NOT NULL,
+ destination varchar(320) NOT NULL,
+ CONSTRAINT pkey_catchall PRIMARY KEY (gid, destination),
+ CONSTRAINT fkey_catchall_gid_domain_data FOREIGN KEY (gid)
+ REFERENCES domain_data (gid)
+);
+
+-- ---
-- Restore view
-- ---
CREATE VIEW vmm_domain_info AS
--- a/pgsql/update_tables_0.5.x-0.6.pgsql Sun Apr 08 19:05:25 2012 +0000
+++ b/pgsql/update_tables_0.5.x-0.6.pgsql Mon Apr 09 17:45:02 2012 +0200
@@ -143,6 +143,18 @@
FOREIGN KEY (ssid) REFERENCES service_set (ssid);
-- ---
+-- Catchall
+-- ---
+
+CREATE TABLE catchall (
+ gid bigint NOT NULL,
+ destination varchar(320) NOT NULL,
+ CONSTRAINT pkey_catchall PRIMARY KEY (gid, destination),
+ CONSTRAINT fkey_catchall_gid_domain_data FOREIGN KEY (gid)
+ REFERENCES domain_data (gid)
+);
+
+-- ---
-- Restore view
-- ---
CREATE VIEW vmm_domain_info AS