# HG changeset patch # User Pascal Volk # Date 1297188247 0 # Node ID dd95ed5bc9d22ea3f40e6182f77bf8cba42eb486 # Parent 05dc4e1f8dff955377d67fb8a33a0e63d767a2c8 pgsql: Added quotalimit's bytes and messages to view vmm_domain_info. diff -r 05dc4e1f8dff -r dd95ed5bc9d2 pgsql/create_tables-dovecot-1.2.x.pgsql --- a/pgsql/create_tables-dovecot-1.2.x.pgsql Tue Feb 08 13:43:35 2011 +0000 +++ b/pgsql/create_tables-dovecot-1.2.x.pgsql Tue Feb 08 18:04:07 2011 +0000 @@ -203,13 +203,15 @@ (SELECT count(gid) FROM domain_name WHERE domain_name.gid = domain_data.gid - AND NOT domain_name.is_primary) AS aliasdomains + AND NOT domain_name.is_primary) AS aliasdomains, + bytes, messages FROM domain_data LEFT JOIN domain_name USING (gid) + LEFT JOIN quotalimit USING (qid) LEFT JOIN transport USING (tid) LEFT JOIN users USING (gid) WHERE domain_name.is_primary - GROUP BY gid, domainname, transport, domaindir; + GROUP BY gid, domainname, transport, domaindir, bytes, messages; CREATE LANGUAGE plpgsql; diff -r 05dc4e1f8dff -r dd95ed5bc9d2 pgsql/create_tables.pgsql --- a/pgsql/create_tables.pgsql Tue Feb 08 13:43:35 2011 +0000 +++ b/pgsql/create_tables.pgsql Tue Feb 08 18:04:07 2011 +0000 @@ -203,13 +203,15 @@ (SELECT count(gid) FROM domain_name WHERE domain_name.gid = domain_data.gid - AND NOT domain_name.is_primary) AS aliasdomains + AND NOT domain_name.is_primary) AS aliasdomains, + bytes, messages FROM domain_data LEFT JOIN domain_name USING (gid) + LEFT JOIN quotalimit USING (qid) LEFT JOIN transport USING (tid) LEFT JOIN users USING (gid) WHERE domain_name.is_primary - GROUP BY gid, domainname, transport, domaindir; + GROUP BY gid, domainname, transport, domaindir, bytes, messages; CREATE LANGUAGE plpgsql; diff -r 05dc4e1f8dff -r dd95ed5bc9d2 pgsql/update_tables_0.5.x-0.6-dovecot-1.2.x.pgsql --- a/pgsql/update_tables_0.5.x-0.6-dovecot-1.2.x.pgsql Tue Feb 08 13:43:35 2011 +0000 +++ b/pgsql/update_tables_0.5.x-0.6-dovecot-1.2.x.pgsql Tue Feb 08 18:04:07 2011 +0000 @@ -135,3 +135,25 @@ LEFT JOIN domain_data USING (gid) LEFT JOIN domain_name USING (gid) LEFT JOIN maillocation USING (mid); + +CREATE OR REPLACE VIEW vmm_domain_info AS + SELECT gid, domainname, transport, domaindir, + count(uid) AS accounts, + (SELECT count(DISTINCT address) + FROM alias + WHERE alias.gid = domain_data.gid) AS aliases, + (SELECT count(gid) + FROM relocated + WHERE relocated.gid = domain_data.gid) AS relocated, + (SELECT count(gid) + FROM domain_name + WHERE domain_name.gid = domain_data.gid + AND NOT domain_name.is_primary) AS aliasdomains, + bytes, messages + FROM domain_data + LEFT JOIN domain_name USING (gid) + LEFT JOIN quotalimit USING (qid) + LEFT JOIN transport USING (tid) + LEFT JOIN users USING (gid) + WHERE domain_name.is_primary + GROUP BY gid, domainname, transport, domaindir, bytes, messages; diff -r 05dc4e1f8dff -r dd95ed5bc9d2 pgsql/update_tables_0.5.x-0.6.pgsql --- a/pgsql/update_tables_0.5.x-0.6.pgsql Tue Feb 08 13:43:35 2011 +0000 +++ b/pgsql/update_tables_0.5.x-0.6.pgsql Tue Feb 08 18:04:07 2011 +0000 @@ -113,3 +113,25 @@ LEFT JOIN domain_data USING (gid) LEFT JOIN domain_name USING (gid) LEFT JOIN maillocation USING (mid); + +CREATE OR REPLACE VIEW vmm_domain_info AS + SELECT gid, domainname, transport, domaindir, + count(uid) AS accounts, + (SELECT count(DISTINCT address) + FROM alias + WHERE alias.gid = domain_data.gid) AS aliases, + (SELECT count(gid) + FROM relocated + WHERE relocated.gid = domain_data.gid) AS relocated, + (SELECT count(gid) + FROM domain_name + WHERE domain_name.gid = domain_data.gid + AND NOT domain_name.is_primary) AS aliasdomains, + bytes, messages + FROM domain_data + LEFT JOIN domain_name USING (gid) + LEFT JOIN quotalimit USING (qid) + LEFT JOIN transport USING (tid) + LEFT JOIN users USING (gid) + WHERE domain_name.is_primary + GROUP BY gid, domainname, transport, domaindir, bytes, messages;