author | Pascal Volk <neverseen@users.sourceforge.net> |
Fri, 11 Feb 2011 02:11:15 +0000 | |
branch | v0.6.x |
changeset 393 | fb2ba1456bc5 |
parent 391 | 8217ddd5220d |
child 437 | 9823548b2717 |
permissions | -rw-r--r-- |
297
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1 |
SET client_encoding = 'UTF8'; |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
2 |
SET client_min_messages = warning; |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
3 |
|
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
4 |
|
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
5 |
-- --- |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
6 |
-- Make room for sha512-crypt.hex hashed passwords |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
7 |
-- --- |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
8 |
DROP VIEW dovecot_password; |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
9 |
|
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
10 |
ALTER TABLE users ALTER COLUMN passwd TYPE varchar(270); |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
11 |
|
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
12 |
CREATE VIEW dovecot_password AS |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
13 |
SELECT local_part || '@' || domain_name.domainname AS "user", |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
14 |
passwd AS "password", smtp, pop3, imap, managesieve |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
15 |
FROM users |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
16 |
LEFT JOIN domain_name USING (gid); |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
17 |
|
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
18 |
-- --- |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
19 |
-- Make room for different mailbox formats. |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
20 |
-- --- |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
21 |
DROP VIEW dovecot_user; |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
22 |
DROP VIEW postfix_maildir; |
391
8217ddd5220d
pgsql: Updated view vmm_domain_info. No longer select data we have already.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
388
diff
changeset
|
23 |
DROP VIEW vmm_domain_info; |
297
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
24 |
|
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
25 |
CREATE SEQUENCE mailboxformat_id; |
382
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
26 |
CREATE SEQUENCE quotalimit_id; |
297
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
27 |
|
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
28 |
CREATE TABLE mailboxformat ( |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
29 |
fid bigint NOT NULL DEFAULT nextval('mailboxformat_id'), |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
30 |
format varchar(20) NOT NULL, |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
31 |
CONSTRAINT pkey_mailboxformat PRIMARY KEY (fid), |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
32 |
CONSTRAINT ukey_mailboxformat UNIQUE (format) |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
33 |
); |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
34 |
-- Insert supported mailbox formats |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
35 |
INSERT INTO mailboxformat(format) VALUES ('maildir'); |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
36 |
INSERT INTO mailboxformat(format) VALUES ('mdbox'); |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
37 |
INSERT INTO mailboxformat(format) VALUES ('sdbox'); |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
38 |
|
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
39 |
-- Adjust maillocation table |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
40 |
ALTER TABLE maillocation DROP CONSTRAINT ukey_maillocation; |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
41 |
ALTER TABLE maillocation RENAME COLUMN maillocation TO directory; |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
42 |
ALTER TABLE maillocation |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
43 |
ADD COLUMN fid bigint NOT NULL DEFAULT 1, |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
44 |
ADD COLUMN extra varchar(1024); |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
45 |
ALTER TABLE maillocation ADD CONSTRAINT fkey_maillocation_fid_mailboxformat |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
46 |
FOREIGN KEY (fid) REFERENCES mailboxformat (fid); |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
47 |
|
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
48 |
|
382
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
49 |
-- --- |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
50 |
-- Add quota stuff |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
51 |
-- --- |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
52 |
CREATE TABLE quotalimit ( |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
53 |
qid bigint NOT NULL DEFAULT nextval('quotalimit_id'), |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
54 |
bytes bigint NOT NULL, |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
55 |
messages integer NOT NULL DEFAULT 0, |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
56 |
CONSTRAINT pkey_quotalimit PRIMARY KEY (qid), |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
57 |
CONSTRAINT ukey_quotalimit UNIQUE (bytes, messages) |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
58 |
); |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
59 |
-- Insert default (non) quota limit |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
60 |
INSERT INTO quotalimit(bytes, messages) VALUES (0, 0); |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
61 |
|
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
62 |
-- Adjust tables … |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
63 |
ALTER TABLE domain_data ADD COLUMN qid bigint NOT NULL DEFAULT 1; |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
64 |
ALTER TABLE domain_data ADD CONSTRAINT fkey_domain_data_qid_quotalimit |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
65 |
FOREIGN KEY (qid) REFERENCES quotalimit (qid); |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
66 |
|
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
67 |
ALTER TABLE users ADD COLUMN qid bigint NOT NULL DEFAULT 1; |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
68 |
ALTER TABLE users ADD CONSTRAINT fkey_users_qid_quotalimit |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
69 |
FOREIGN KEY (qid) REFERENCES quotalimit (qid); |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
70 |
|
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
71 |
CREATE TABLE userquota_11 ( |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
72 |
uid bigint NOT NULL, |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
73 |
path varchar(16) NOT NULL, |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
74 |
current bigint NOT NULL DEFAULT 0, |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
75 |
CONSTRAINT pkey_userquota_11 PRIMARY KEY (uid, path), |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
76 |
CONSTRAINT fkey_userquota_11_uid_users FOREIGN KEY (uid) |
387
05dc4e1f8dff
pgsql/{create,update}_tables*: Added the ON DELETE CASCADE clause
Pascal Volk <neverseen@users.sourceforge.net>
parents:
382
diff
changeset
|
77 |
REFERENCES users (uid) ON DELETE CASCADE |
382
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
78 |
); |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
79 |
|
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
80 |
CREATE OR REPLACE FUNCTION merge_userquota_11() RETURNS TRIGGER AS $$ |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
81 |
BEGIN |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
82 |
UPDATE userquota_11 |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
83 |
SET current = current + NEW.current |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
84 |
WHERE uid = NEW.uid AND path = NEW.path; |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
85 |
IF found THEN |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
86 |
RETURN NULL; |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
87 |
ELSE |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
88 |
RETURN NEW; |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
89 |
END IF; |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
90 |
END; |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
91 |
$$ LANGUAGE plpgsql; |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
92 |
|
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
93 |
CREATE TRIGGER mergeuserquota_11 BEFORE INSERT ON userquota_11 |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
94 |
FOR EACH ROW EXECUTE PROCEDURE merge_userquota_11(); |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
95 |
|
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
96 |
-- --- |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
97 |
-- Restore views |
5e6bcb2e010e
pgsql/*: Added tables, triggers and functions for quota support.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
297
diff
changeset
|
98 |
-- --- |
297
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
99 |
CREATE VIEW dovecot_user AS |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
100 |
SELECT local_part || '@' || domain_name.domainname AS userid, |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
101 |
uid, gid, domain_data.domaindir || '/' || uid AS home, |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
102 |
mailboxformat.format || ':~/' || maillocation.directory AS mail |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
103 |
FROM users |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
104 |
LEFT JOIN domain_data USING (gid) |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
105 |
LEFT JOIN domain_name USING (gid) |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
106 |
LEFT JOIN maillocation USING (mid) |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
107 |
LEFT JOIN mailboxformat USING (fid); |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
108 |
|
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
109 |
CREATE VIEW postfix_maildir AS |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
110 |
SELECT local_part || '@' || domain_name.domainname AS address, |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
111 |
domain_data.domaindir||'/'||uid||'/'||maillocation.directory||'/' |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
112 |
AS maildir |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
113 |
FROM users |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
114 |
LEFT JOIN domain_data USING (gid) |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
115 |
LEFT JOIN domain_name USING (gid) |
e21ceaabe871
pgsql: Added support for different mailbox formats.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
116 |
LEFT JOIN maillocation USING (mid); |
388
dd95ed5bc9d2
pgsql: Added quotalimit's bytes and messages to view vmm_domain_info.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
387
diff
changeset
|
117 |
|
391
8217ddd5220d
pgsql: Updated view vmm_domain_info. No longer select data we have already.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
388
diff
changeset
|
118 |
CREATE VIEW vmm_domain_info AS |
8217ddd5220d
pgsql: Updated view vmm_domain_info. No longer select data we have already.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
388
diff
changeset
|
119 |
SELECT gid, count(uid) AS accounts, |
388
dd95ed5bc9d2
pgsql: Added quotalimit's bytes and messages to view vmm_domain_info.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
387
diff
changeset
|
120 |
(SELECT count(DISTINCT address) |
dd95ed5bc9d2
pgsql: Added quotalimit's bytes and messages to view vmm_domain_info.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
387
diff
changeset
|
121 |
FROM alias |
dd95ed5bc9d2
pgsql: Added quotalimit's bytes and messages to view vmm_domain_info.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
387
diff
changeset
|
122 |
WHERE alias.gid = domain_data.gid) AS aliases, |
dd95ed5bc9d2
pgsql: Added quotalimit's bytes and messages to view vmm_domain_info.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
387
diff
changeset
|
123 |
(SELECT count(gid) |
dd95ed5bc9d2
pgsql: Added quotalimit's bytes and messages to view vmm_domain_info.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
387
diff
changeset
|
124 |
FROM relocated |
dd95ed5bc9d2
pgsql: Added quotalimit's bytes and messages to view vmm_domain_info.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
387
diff
changeset
|
125 |
WHERE relocated.gid = domain_data.gid) AS relocated, |
dd95ed5bc9d2
pgsql: Added quotalimit's bytes and messages to view vmm_domain_info.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
387
diff
changeset
|
126 |
(SELECT count(gid) |
dd95ed5bc9d2
pgsql: Added quotalimit's bytes and messages to view vmm_domain_info.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
387
diff
changeset
|
127 |
FROM domain_name |
dd95ed5bc9d2
pgsql: Added quotalimit's bytes and messages to view vmm_domain_info.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
387
diff
changeset
|
128 |
WHERE domain_name.gid = domain_data.gid |
391
8217ddd5220d
pgsql: Updated view vmm_domain_info. No longer select data we have already.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
388
diff
changeset
|
129 |
AND NOT domain_name.is_primary) AS aliasdomains |
388
dd95ed5bc9d2
pgsql: Added quotalimit's bytes and messages to view vmm_domain_info.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
387
diff
changeset
|
130 |
FROM domain_data |
dd95ed5bc9d2
pgsql: Added quotalimit's bytes and messages to view vmm_domain_info.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
387
diff
changeset
|
131 |
LEFT JOIN domain_name USING (gid) |
dd95ed5bc9d2
pgsql: Added quotalimit's bytes and messages to view vmm_domain_info.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
387
diff
changeset
|
132 |
LEFT JOIN users USING (gid) |
dd95ed5bc9d2
pgsql: Added quotalimit's bytes and messages to view vmm_domain_info.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
387
diff
changeset
|
133 |
WHERE domain_name.is_primary |
391
8217ddd5220d
pgsql: Updated view vmm_domain_info. No longer select data we have already.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
388
diff
changeset
|
134 |
GROUP BY gid; |