create_tables.pgsql
changeset 80 5dedc673524e
parent 71 4c94ba297698
child 102 485d3f7d6981
--- a/create_tables.pgsql	Mon Sep 08 23:47:34 2008 +0000
+++ b/create_tables.pgsql	Tue Sep 09 04:29:13 2008 +0000
@@ -149,15 +149,15 @@
            LEFT JOIN transport USING (tid)
            LEFT JOIN domain_name USING (gid);
 
-CREATE OR REPLACE VIEW vmm_alias_count AS
-    SELECT count(DISTINCT address) AS aliases, gid
-      FROM alias 
-  GROUP BY gid;
-
 CREATE OR REPLACE VIEW vmm_domain_info AS
     SELECT gid, domainname, transport, domaindir,
            count(uid) AS accounts,
-           aliases,
+           (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
@@ -166,9 +166,8 @@
            LEFT JOIN domain_name USING (gid)
            LEFT JOIN transport USING (tid)
            LEFT JOIN users USING (gid)
-           LEFT JOIN vmm_alias_count USING (gid)
      WHERE domain_name.is_primary
-  GROUP BY gid, domainname, transport, domaindir, aliases;
+  GROUP BY gid, domainname, transport, domaindir;
 
 
 CREATE LANGUAGE plpgsql;