mailshears 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +32 -0
  3. data/bin/install-fixtures.sh +27 -0
  4. data/bin/mailshears +124 -0
  5. data/doc/LICENSE +661 -0
  6. data/doc/TODO +16 -0
  7. data/doc/mailshears.example.conf.yml +37 -0
  8. data/doc/man1/mailshears.1 +184 -0
  9. data/lib/common/agendav_plugin.rb +54 -0
  10. data/lib/common/configuration.rb +116 -0
  11. data/lib/common/davical_plugin.rb +104 -0
  12. data/lib/common/domain.rb +64 -0
  13. data/lib/common/dovecot_plugin.rb +130 -0
  14. data/lib/common/errors.rb +15 -0
  15. data/lib/common/exit_codes.rb +9 -0
  16. data/lib/common/filesystem.rb +43 -0
  17. data/lib/common/plugin.rb +238 -0
  18. data/lib/common/postfixadmin_plugin.rb +180 -0
  19. data/lib/common/roundcube_plugin.rb +96 -0
  20. data/lib/common/runner.rb +73 -0
  21. data/lib/common/user.rb +120 -0
  22. data/lib/common/user_interface.rb +53 -0
  23. data/lib/mailshears.rb +7 -0
  24. data/lib/mv/mv_dummy_runner.rb +45 -0
  25. data/lib/mv/mv_plugin.rb +40 -0
  26. data/lib/mv/mv_runner.rb +56 -0
  27. data/lib/mv/plugins/agendav.rb +46 -0
  28. data/lib/mv/plugins/davical.rb +43 -0
  29. data/lib/mv/plugins/dovecot.rb +64 -0
  30. data/lib/mv/plugins/postfixadmin.rb +70 -0
  31. data/lib/mv/plugins/roundcube.rb +44 -0
  32. data/lib/prune/plugins/agendav.rb +13 -0
  33. data/lib/prune/plugins/davical.rb +13 -0
  34. data/lib/prune/plugins/dovecot.rb +11 -0
  35. data/lib/prune/plugins/postfixadmin.rb +13 -0
  36. data/lib/prune/plugins/roundcube.rb +14 -0
  37. data/lib/prune/prune_dummy_runner.rb +44 -0
  38. data/lib/prune/prune_plugin.rb +66 -0
  39. data/lib/prune/prune_runner.rb +34 -0
  40. data/lib/rm/plugins/agendav.rb +38 -0
  41. data/lib/rm/plugins/davical.rb +38 -0
  42. data/lib/rm/plugins/dovecot.rb +48 -0
  43. data/lib/rm/plugins/postfixadmin.rb +114 -0
  44. data/lib/rm/plugins/roundcube.rb +42 -0
  45. data/lib/rm/rm_dummy_runner.rb +39 -0
  46. data/lib/rm/rm_plugin.rb +77 -0
  47. data/lib/rm/rm_runner.rb +51 -0
  48. data/mailshears.gemspec +39 -0
  49. data/test/mailshears.test.conf.yml +36 -0
  50. data/test/mailshears_test.rb +250 -0
  51. data/test/sql/agendav-fixtures.sql +9 -0
  52. data/test/sql/agendav.sql +157 -0
  53. data/test/sql/davical-fixtures.sql +23 -0
  54. data/test/sql/davical.sql +4371 -0
  55. data/test/sql/postfixadmin-fixtures.sql +48 -0
  56. data/test/sql/postfixadmin.sql +737 -0
  57. data/test/sql/roundcube-fixtures.sql +4 -0
  58. data/test/sql/roundcube.sql +608 -0
  59. data/test/test_mv.rb +174 -0
  60. data/test/test_prune.rb +121 -0
  61. data/test/test_rm.rb +154 -0
  62. metadata +133 -0
@@ -0,0 +1,48 @@
1
+ /* This is a magic record, always included as the first row of the
2
+ * domain table.
3
+ */
4
+ INSERT INTO domain (domain) VALUES ('ALL');
5
+
6
+ /* Create two domains, example.com, and example.net. */
7
+ INSERT INTO domain (domain) VALUES ('example.com');
8
+ INSERT INTO domain (domain) VALUES ('example.net');
9
+
10
+ /*
11
+ * Now create their mailboxes, two in one domain, and three in the
12
+ * other.
13
+ */
14
+ INSERT INTO mailbox (username, domain, local_part)
15
+ VALUES ('alice@example.com', 'example.com', 'alice');
16
+ INSERT INTO mailbox (username, domain, local_part)
17
+ VALUES ('bob@example.com', 'example.com', 'bob');
18
+
19
+ INSERT INTO mailbox (username, domain, local_part)
20
+ VALUES ('adam@example.net', 'example.net', 'adam');
21
+ INSERT INTO mailbox (username, domain, local_part)
22
+ VALUES ('beth@example.net', 'example.net', 'beth');
23
+ INSERT INTO mailbox (username, domain, local_part)
24
+ VALUES ('carol@example.net', 'example.net', 'carol');
25
+
26
+ /* Each mailbox has an alias pointing to (at least) itself. */
27
+ INSERT INTO alias (address, goto, domain)
28
+ VALUES ('bob@example.com', 'bob@example.com', 'example.com');
29
+ INSERT INTO alias (address, goto, domain)
30
+ VALUES ('adam@example.net', 'adam@example.net', 'example.net');
31
+ INSERT INTO alias (address, goto, domain)
32
+ VALUES ('beth@example.net', 'beth@example.net', 'example.net');
33
+ INSERT INTO alias (address, goto, domain)
34
+ VALUES ('carol@example.net', 'carol@example.net', 'example.net');
35
+
36
+ /* Alice is aliased to some other people, too. */
37
+ INSERT INTO alias (address, goto, domain)
38
+ VALUES
39
+ ('alice@example.com',
40
+ 'alice@example.com,adam@example.net,bob@example.com,carol@example.net',
41
+ 'example.com');
42
+
43
+ /* Create a domain admin for both example.com and example.net. */
44
+ INSERT INTO domain_admins (username, domain)
45
+ VALUES ('admin@example.com', 'example.com');
46
+ INSERT INTO domain_admins (username, domain)
47
+ VALUES ('admin@example.com', 'example.net');
48
+
@@ -0,0 +1,737 @@
1
+ --
2
+ -- PostgreSQL database dump
3
+ --
4
+
5
+ SET statement_timeout = 0;
6
+ SET client_encoding = 'UTF8';
7
+ SET standard_conforming_strings = on;
8
+ SET check_function_bodies = false;
9
+ SET client_min_messages = warning;
10
+
11
+ --
12
+ -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner:
13
+ --
14
+
15
+ CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
16
+
17
+
18
+ --
19
+ -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner:
20
+ --
21
+
22
+ COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
23
+
24
+
25
+ SET search_path = public, pg_catalog;
26
+
27
+ --
28
+ -- Name: merge_quota(); Type: FUNCTION; Schema: public; Owner: postgres
29
+ --
30
+
31
+ CREATE FUNCTION merge_quota() RETURNS trigger
32
+ LANGUAGE plpgsql
33
+ AS $$
34
+ BEGIN
35
+ UPDATE quota SET current = NEW.current + current WHERE username = NEW.username AND path = NEW.path;
36
+ IF found THEN
37
+ RETURN NULL;
38
+ ELSE
39
+ RETURN NEW;
40
+ END IF;
41
+ END;
42
+ $$;
43
+
44
+
45
+ ALTER FUNCTION public.merge_quota() OWNER TO postgres;
46
+
47
+ --
48
+ -- Name: merge_quota2(); Type: FUNCTION; Schema: public; Owner: postgres
49
+ --
50
+
51
+ CREATE FUNCTION merge_quota2() RETURNS trigger
52
+ LANGUAGE plpgsql
53
+ AS $$
54
+ BEGIN
55
+ IF NEW.messages < 0 OR NEW.messages IS NULL THEN
56
+ -- ugly kludge: we came here from this function, really do try to insert
57
+ IF NEW.messages IS NULL THEN
58
+ NEW.messages = 0;
59
+ ELSE
60
+ NEW.messages = -NEW.messages;
61
+ END IF;
62
+ return NEW;
63
+ END IF;
64
+
65
+ LOOP
66
+ UPDATE quota2 SET bytes = bytes + NEW.bytes,
67
+ messages = messages + NEW.messages
68
+ WHERE username = NEW.username;
69
+ IF found THEN
70
+ RETURN NULL;
71
+ END IF;
72
+
73
+ BEGIN
74
+ IF NEW.messages = 0 THEN
75
+ INSERT INTO quota2 (bytes, messages, username) VALUES (NEW.bytes, NULL, NEW.username);
76
+ ELSE
77
+ INSERT INTO quota2 (bytes, messages, username) VALUES (NEW.bytes, -NEW.messages, NEW.username);
78
+ END IF;
79
+ return NULL;
80
+ EXCEPTION WHEN unique_violation THEN
81
+ -- someone just inserted the record, update it
82
+ END;
83
+ END LOOP;
84
+ END;
85
+ $$;
86
+
87
+
88
+ ALTER FUNCTION public.merge_quota2() OWNER TO postgres;
89
+
90
+ SET default_tablespace = '';
91
+
92
+ SET default_with_oids = true;
93
+
94
+ --
95
+ -- Name: admin; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
96
+ --
97
+
98
+ CREATE TABLE admin (
99
+ username character varying(255) NOT NULL,
100
+ password character varying(255) DEFAULT ''::character varying NOT NULL,
101
+ created timestamp with time zone DEFAULT now(),
102
+ modified timestamp with time zone DEFAULT now(),
103
+ active boolean DEFAULT true NOT NULL
104
+ );
105
+
106
+
107
+ ALTER TABLE public.admin OWNER TO postgres;
108
+
109
+ --
110
+ -- Name: TABLE admin; Type: COMMENT; Schema: public; Owner: postgres
111
+ --
112
+
113
+ COMMENT ON TABLE admin IS 'Postfix Admin - Virtual Admins';
114
+
115
+
116
+ --
117
+ -- Name: alias; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
118
+ --
119
+
120
+ CREATE TABLE alias (
121
+ address character varying(255) NOT NULL,
122
+ goto text NOT NULL,
123
+ domain character varying(255) NOT NULL,
124
+ created timestamp with time zone DEFAULT now(),
125
+ modified timestamp with time zone DEFAULT now(),
126
+ active boolean DEFAULT true NOT NULL
127
+ );
128
+
129
+
130
+ ALTER TABLE public.alias OWNER TO postgres;
131
+
132
+ --
133
+ -- Name: TABLE alias; Type: COMMENT; Schema: public; Owner: postgres
134
+ --
135
+
136
+ COMMENT ON TABLE alias IS 'Postfix Admin - Virtual Aliases';
137
+
138
+
139
+ SET default_with_oids = false;
140
+
141
+ --
142
+ -- Name: alias_domain; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
143
+ --
144
+
145
+ CREATE TABLE alias_domain (
146
+ alias_domain character varying(255) NOT NULL,
147
+ target_domain character varying(255) NOT NULL,
148
+ created timestamp with time zone DEFAULT now(),
149
+ modified timestamp with time zone DEFAULT now(),
150
+ active boolean DEFAULT true NOT NULL
151
+ );
152
+
153
+
154
+ ALTER TABLE public.alias_domain OWNER TO postgres;
155
+
156
+ --
157
+ -- Name: TABLE alias_domain; Type: COMMENT; Schema: public; Owner: postgres
158
+ --
159
+
160
+ COMMENT ON TABLE alias_domain IS 'Postfix Admin - Domain Aliases';
161
+
162
+
163
+ SET default_with_oids = true;
164
+
165
+ --
166
+ -- Name: config; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
167
+ --
168
+
169
+ CREATE TABLE config (
170
+ id integer NOT NULL,
171
+ name character varying(20) NOT NULL,
172
+ value character varying(20) NOT NULL
173
+ );
174
+
175
+
176
+ ALTER TABLE public.config OWNER TO postgres;
177
+
178
+ --
179
+ -- Name: config_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
180
+ --
181
+
182
+ CREATE SEQUENCE config_id_seq
183
+ START WITH 1
184
+ INCREMENT BY 1
185
+ NO MINVALUE
186
+ NO MAXVALUE
187
+ CACHE 1;
188
+
189
+
190
+ ALTER TABLE public.config_id_seq OWNER TO postgres;
191
+
192
+ --
193
+ -- Name: config_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
194
+ --
195
+
196
+ ALTER SEQUENCE config_id_seq OWNED BY config.id;
197
+
198
+
199
+ --
200
+ -- Name: domain; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
201
+ --
202
+
203
+ CREATE TABLE domain (
204
+ domain character varying(255) NOT NULL,
205
+ description character varying(255) DEFAULT ''::character varying NOT NULL,
206
+ aliases integer DEFAULT 0 NOT NULL,
207
+ mailboxes integer DEFAULT 0 NOT NULL,
208
+ maxquota bigint DEFAULT 0 NOT NULL,
209
+ quota bigint DEFAULT 0 NOT NULL,
210
+ transport character varying(255),
211
+ backupmx boolean DEFAULT false NOT NULL,
212
+ created timestamp with time zone DEFAULT now(),
213
+ modified timestamp with time zone DEFAULT now(),
214
+ active boolean DEFAULT true NOT NULL
215
+ );
216
+
217
+
218
+ ALTER TABLE public.domain OWNER TO postgres;
219
+
220
+ --
221
+ -- Name: TABLE domain; Type: COMMENT; Schema: public; Owner: postgres
222
+ --
223
+
224
+ COMMENT ON TABLE domain IS 'Postfix Admin - Virtual Domains';
225
+
226
+
227
+ --
228
+ -- Name: domain_admins; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
229
+ --
230
+
231
+ CREATE TABLE domain_admins (
232
+ username character varying(255) NOT NULL,
233
+ domain character varying(255) NOT NULL,
234
+ created timestamp with time zone DEFAULT now(),
235
+ active boolean DEFAULT true NOT NULL
236
+ );
237
+
238
+
239
+ ALTER TABLE public.domain_admins OWNER TO postgres;
240
+
241
+ --
242
+ -- Name: TABLE domain_admins; Type: COMMENT; Schema: public; Owner: postgres
243
+ --
244
+
245
+ COMMENT ON TABLE domain_admins IS 'Postfix Admin - Domain Admins';
246
+
247
+
248
+ --
249
+ -- Name: fetchmail; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
250
+ --
251
+
252
+ CREATE TABLE fetchmail (
253
+ id integer NOT NULL,
254
+ mailbox character varying(255) DEFAULT ''::character varying NOT NULL,
255
+ src_server character varying(255) DEFAULT ''::character varying NOT NULL,
256
+ src_auth character varying(15) NOT NULL,
257
+ src_user character varying(255) DEFAULT ''::character varying NOT NULL,
258
+ src_password character varying(255) DEFAULT ''::character varying NOT NULL,
259
+ src_folder character varying(255) DEFAULT ''::character varying NOT NULL,
260
+ poll_time integer DEFAULT 10 NOT NULL,
261
+ fetchall boolean DEFAULT false NOT NULL,
262
+ keep boolean DEFAULT false NOT NULL,
263
+ protocol character varying(15) NOT NULL,
264
+ extra_options text,
265
+ returned_text text,
266
+ mda character varying(255) DEFAULT ''::character varying NOT NULL,
267
+ date timestamp with time zone DEFAULT now(),
268
+ usessl boolean DEFAULT false NOT NULL,
269
+ CONSTRAINT fetchmail_protocol_check CHECK (((((((protocol)::text = 'POP3'::text) OR ((protocol)::text = 'IMAP'::text)) OR ((protocol)::text = 'POP2'::text)) OR ((protocol)::text = 'ETRN'::text)) OR ((protocol)::text = 'AUTO'::text))),
270
+ CONSTRAINT fetchmail_src_auth_check CHECK (((((((((((((src_auth)::text = 'password'::text) OR ((src_auth)::text = 'kerberos_v5'::text)) OR ((src_auth)::text = 'kerberos'::text)) OR ((src_auth)::text = 'kerberos_v4'::text)) OR ((src_auth)::text = 'gssapi'::text)) OR ((src_auth)::text = 'cram-md5'::text)) OR ((src_auth)::text = 'otp'::text)) OR ((src_auth)::text = 'ntlm'::text)) OR ((src_auth)::text = 'msn'::text)) OR ((src_auth)::text = 'ssh'::text)) OR ((src_auth)::text = 'any'::text)))
271
+ );
272
+
273
+
274
+ ALTER TABLE public.fetchmail OWNER TO postgres;
275
+
276
+ --
277
+ -- Name: fetchmail_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
278
+ --
279
+
280
+ CREATE SEQUENCE fetchmail_id_seq
281
+ START WITH 1
282
+ INCREMENT BY 1
283
+ NO MINVALUE
284
+ NO MAXVALUE
285
+ CACHE 1;
286
+
287
+
288
+ ALTER TABLE public.fetchmail_id_seq OWNER TO postgres;
289
+
290
+ --
291
+ -- Name: fetchmail_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
292
+ --
293
+
294
+ ALTER SEQUENCE fetchmail_id_seq OWNED BY fetchmail.id;
295
+
296
+
297
+ --
298
+ -- Name: log; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
299
+ --
300
+
301
+ CREATE TABLE log (
302
+ "timestamp" timestamp with time zone DEFAULT now(),
303
+ username character varying(255) DEFAULT ''::character varying NOT NULL,
304
+ domain character varying(255) DEFAULT ''::character varying NOT NULL,
305
+ action character varying(255) DEFAULT ''::character varying NOT NULL,
306
+ data text DEFAULT ''::text NOT NULL
307
+ );
308
+
309
+
310
+ ALTER TABLE public.log OWNER TO postgres;
311
+
312
+ --
313
+ -- Name: TABLE log; Type: COMMENT; Schema: public; Owner: postgres
314
+ --
315
+
316
+ COMMENT ON TABLE log IS 'Postfix Admin - Log';
317
+
318
+
319
+ --
320
+ -- Name: mailbox; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
321
+ --
322
+
323
+ CREATE TABLE mailbox (
324
+ username character varying(255) NOT NULL,
325
+ password character varying(255) DEFAULT ''::character varying NOT NULL,
326
+ name character varying(255) DEFAULT ''::character varying NOT NULL,
327
+ maildir character varying(255) DEFAULT ''::character varying NOT NULL,
328
+ quota bigint DEFAULT 0 NOT NULL,
329
+ created timestamp with time zone DEFAULT now(),
330
+ modified timestamp with time zone DEFAULT now(),
331
+ active boolean DEFAULT true NOT NULL,
332
+ domain character varying(255),
333
+ local_part character varying(255) NOT NULL
334
+ );
335
+
336
+
337
+ ALTER TABLE public.mailbox OWNER TO postgres;
338
+
339
+ --
340
+ -- Name: TABLE mailbox; Type: COMMENT; Schema: public; Owner: postgres
341
+ --
342
+
343
+ COMMENT ON TABLE mailbox IS 'Postfix Admin - Virtual Mailboxes';
344
+
345
+
346
+ SET default_with_oids = false;
347
+
348
+ --
349
+ -- Name: quota; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
350
+ --
351
+
352
+ CREATE TABLE quota (
353
+ username character varying(255) NOT NULL,
354
+ path character varying(100) NOT NULL,
355
+ current bigint
356
+ );
357
+
358
+
359
+ ALTER TABLE public.quota OWNER TO postgres;
360
+
361
+ --
362
+ -- Name: quota2; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
363
+ --
364
+
365
+ CREATE TABLE quota2 (
366
+ username character varying(100) NOT NULL,
367
+ bytes bigint DEFAULT 0 NOT NULL,
368
+ messages integer DEFAULT 0 NOT NULL
369
+ );
370
+
371
+
372
+ ALTER TABLE public.quota2 OWNER TO postgres;
373
+
374
+ SET default_with_oids = true;
375
+
376
+ --
377
+ -- Name: vacation; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
378
+ --
379
+
380
+ CREATE TABLE vacation (
381
+ email character varying(255) NOT NULL,
382
+ subject character varying(255) NOT NULL,
383
+ body text DEFAULT ''::text NOT NULL,
384
+ created timestamp with time zone DEFAULT now(),
385
+ active boolean DEFAULT true NOT NULL,
386
+ domain character varying(255)
387
+ );
388
+
389
+
390
+ ALTER TABLE public.vacation OWNER TO postgres;
391
+
392
+ --
393
+ -- Name: vacation_notification; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
394
+ --
395
+
396
+ CREATE TABLE vacation_notification (
397
+ on_vacation character varying(255) NOT NULL,
398
+ notified character varying(255) NOT NULL,
399
+ notified_at timestamp with time zone DEFAULT now() NOT NULL
400
+ );
401
+
402
+
403
+ ALTER TABLE public.vacation_notification OWNER TO postgres;
404
+
405
+ --
406
+ -- Name: id; Type: DEFAULT; Schema: public; Owner: postgres
407
+ --
408
+
409
+ ALTER TABLE ONLY config ALTER COLUMN id SET DEFAULT nextval('config_id_seq'::regclass);
410
+
411
+
412
+ --
413
+ -- Name: id; Type: DEFAULT; Schema: public; Owner: postgres
414
+ --
415
+
416
+ ALTER TABLE ONLY fetchmail ALTER COLUMN id SET DEFAULT nextval('fetchmail_id_seq'::regclass);
417
+
418
+
419
+ --
420
+ -- Name: admin_key; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
421
+ --
422
+
423
+ ALTER TABLE ONLY admin
424
+ ADD CONSTRAINT admin_key PRIMARY KEY (username);
425
+
426
+
427
+ --
428
+ -- Name: alias_domain_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
429
+ --
430
+
431
+ ALTER TABLE ONLY alias_domain
432
+ ADD CONSTRAINT alias_domain_pkey PRIMARY KEY (alias_domain);
433
+
434
+
435
+ --
436
+ -- Name: alias_key; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
437
+ --
438
+
439
+ ALTER TABLE ONLY alias
440
+ ADD CONSTRAINT alias_key PRIMARY KEY (address);
441
+
442
+
443
+ --
444
+ -- Name: config_name_key; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
445
+ --
446
+
447
+ ALTER TABLE ONLY config
448
+ ADD CONSTRAINT config_name_key UNIQUE (name);
449
+
450
+
451
+ --
452
+ -- Name: config_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
453
+ --
454
+
455
+ ALTER TABLE ONLY config
456
+ ADD CONSTRAINT config_pkey PRIMARY KEY (id);
457
+
458
+
459
+ --
460
+ -- Name: domain_key; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
461
+ --
462
+
463
+ ALTER TABLE ONLY domain
464
+ ADD CONSTRAINT domain_key PRIMARY KEY (domain);
465
+
466
+
467
+ --
468
+ -- Name: fetchmail_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
469
+ --
470
+
471
+ ALTER TABLE ONLY fetchmail
472
+ ADD CONSTRAINT fetchmail_pkey PRIMARY KEY (id);
473
+
474
+
475
+ --
476
+ -- Name: mailbox_key; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
477
+ --
478
+
479
+ ALTER TABLE ONLY mailbox
480
+ ADD CONSTRAINT mailbox_key PRIMARY KEY (username);
481
+
482
+
483
+ --
484
+ -- Name: quota2_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
485
+ --
486
+
487
+ ALTER TABLE ONLY quota2
488
+ ADD CONSTRAINT quota2_pkey PRIMARY KEY (username);
489
+
490
+
491
+ --
492
+ -- Name: quota_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
493
+ --
494
+
495
+ ALTER TABLE ONLY quota
496
+ ADD CONSTRAINT quota_pkey PRIMARY KEY (username, path);
497
+
498
+
499
+ --
500
+ -- Name: vacation_notification_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
501
+ --
502
+
503
+ ALTER TABLE ONLY vacation_notification
504
+ ADD CONSTRAINT vacation_notification_pkey PRIMARY KEY (on_vacation, notified);
505
+
506
+
507
+ --
508
+ -- Name: vacation_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
509
+ --
510
+
511
+ ALTER TABLE ONLY vacation
512
+ ADD CONSTRAINT vacation_pkey PRIMARY KEY (email);
513
+
514
+
515
+ --
516
+ -- Name: alias_address_active; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
517
+ --
518
+
519
+ CREATE INDEX alias_address_active ON alias USING btree (address, active);
520
+
521
+
522
+ --
523
+ -- Name: alias_domain_active; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
524
+ --
525
+
526
+ CREATE INDEX alias_domain_active ON alias_domain USING btree (alias_domain, active);
527
+
528
+
529
+ --
530
+ -- Name: alias_domain_idx; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
531
+ --
532
+
533
+ CREATE INDEX alias_domain_idx ON alias USING btree (domain);
534
+
535
+
536
+ --
537
+ -- Name: domain_domain_active; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
538
+ --
539
+
540
+ CREATE INDEX domain_domain_active ON domain USING btree (domain, active);
541
+
542
+
543
+ --
544
+ -- Name: mailbox_domain_idx; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
545
+ --
546
+
547
+ CREATE INDEX mailbox_domain_idx ON mailbox USING btree (domain);
548
+
549
+
550
+ --
551
+ -- Name: mailbox_username_active; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
552
+ --
553
+
554
+ CREATE INDEX mailbox_username_active ON mailbox USING btree (username, active);
555
+
556
+
557
+ --
558
+ -- Name: vacation_email_active; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
559
+ --
560
+
561
+ CREATE INDEX vacation_email_active ON vacation USING btree (email, active);
562
+
563
+
564
+ --
565
+ -- Name: mergequota; Type: TRIGGER; Schema: public; Owner: postgres
566
+ --
567
+
568
+ CREATE TRIGGER mergequota BEFORE INSERT ON quota FOR EACH ROW EXECUTE PROCEDURE merge_quota();
569
+
570
+
571
+ --
572
+ -- Name: mergequota2; Type: TRIGGER; Schema: public; Owner: postgres
573
+ --
574
+
575
+ CREATE TRIGGER mergequota2 BEFORE INSERT ON quota2 FOR EACH ROW EXECUTE PROCEDURE merge_quota2();
576
+
577
+
578
+ --
579
+ -- Name: alias_domain_alias_domain_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
580
+ --
581
+
582
+ ALTER TABLE ONLY alias_domain
583
+ ADD CONSTRAINT alias_domain_alias_domain_fkey FOREIGN KEY (alias_domain) REFERENCES domain(domain) ON DELETE CASCADE;
584
+
585
+
586
+ --
587
+ -- Name: alias_domain_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
588
+ --
589
+
590
+ ALTER TABLE ONLY alias
591
+ ADD CONSTRAINT alias_domain_fkey FOREIGN KEY (domain) REFERENCES domain(domain);
592
+
593
+
594
+ --
595
+ -- Name: alias_domain_target_domain_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
596
+ --
597
+
598
+ ALTER TABLE ONLY alias_domain
599
+ ADD CONSTRAINT alias_domain_target_domain_fkey FOREIGN KEY (target_domain) REFERENCES domain(domain) ON DELETE CASCADE;
600
+
601
+
602
+ --
603
+ -- Name: domain_admins_domain_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
604
+ --
605
+
606
+ ALTER TABLE ONLY domain_admins
607
+ ADD CONSTRAINT domain_admins_domain_fkey FOREIGN KEY (domain) REFERENCES domain(domain);
608
+
609
+
610
+ --
611
+ -- Name: mailbox_domain_fkey1; Type: FK CONSTRAINT; Schema: public; Owner: postgres
612
+ --
613
+
614
+ ALTER TABLE ONLY mailbox
615
+ ADD CONSTRAINT mailbox_domain_fkey1 FOREIGN KEY (domain) REFERENCES domain(domain);
616
+
617
+
618
+ --
619
+ -- Name: vacation_domain_fkey1; Type: FK CONSTRAINT; Schema: public; Owner: postgres
620
+ --
621
+
622
+ ALTER TABLE ONLY vacation
623
+ ADD CONSTRAINT vacation_domain_fkey1 FOREIGN KEY (domain) REFERENCES domain(domain);
624
+
625
+
626
+ --
627
+ -- Name: vacation_notification_on_vacation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
628
+ --
629
+
630
+ ALTER TABLE ONLY vacation_notification
631
+ ADD CONSTRAINT vacation_notification_on_vacation_fkey FOREIGN KEY (on_vacation) REFERENCES vacation(email) ON DELETE CASCADE;
632
+
633
+
634
+ --
635
+ -- Name: public; Type: ACL; Schema: -; Owner: postgres
636
+ --
637
+
638
+ REVOKE ALL ON SCHEMA public FROM PUBLIC;
639
+ REVOKE ALL ON SCHEMA public FROM postgres;
640
+ GRANT ALL ON SCHEMA public TO postgres;
641
+ GRANT ALL ON SCHEMA public TO PUBLIC;
642
+
643
+
644
+ --
645
+ -- Name: admin; Type: ACL; Schema: public; Owner: postgres
646
+ --
647
+
648
+ REVOKE ALL ON TABLE admin FROM PUBLIC;
649
+ REVOKE ALL ON TABLE admin FROM postgres;
650
+ GRANT ALL ON TABLE admin TO postgres;
651
+
652
+
653
+ --
654
+ -- Name: alias; Type: ACL; Schema: public; Owner: postgres
655
+ --
656
+
657
+ REVOKE ALL ON TABLE alias FROM PUBLIC;
658
+ REVOKE ALL ON TABLE alias FROM postgres;
659
+ GRANT ALL ON TABLE alias TO postgres;
660
+
661
+
662
+ --
663
+ -- Name: config; Type: ACL; Schema: public; Owner: postgres
664
+ --
665
+
666
+ REVOKE ALL ON TABLE config FROM PUBLIC;
667
+ REVOKE ALL ON TABLE config FROM postgres;
668
+ GRANT ALL ON TABLE config TO postgres;
669
+
670
+
671
+ --
672
+ -- Name: domain; Type: ACL; Schema: public; Owner: postgres
673
+ --
674
+
675
+ REVOKE ALL ON TABLE domain FROM PUBLIC;
676
+ REVOKE ALL ON TABLE domain FROM postgres;
677
+ GRANT ALL ON TABLE domain TO postgres;
678
+
679
+
680
+ --
681
+ -- Name: domain_admins; Type: ACL; Schema: public; Owner: postgres
682
+ --
683
+
684
+ REVOKE ALL ON TABLE domain_admins FROM PUBLIC;
685
+ REVOKE ALL ON TABLE domain_admins FROM postgres;
686
+ GRANT ALL ON TABLE domain_admins TO postgres;
687
+
688
+
689
+ --
690
+ -- Name: fetchmail; Type: ACL; Schema: public; Owner: postgres
691
+ --
692
+
693
+ REVOKE ALL ON TABLE fetchmail FROM PUBLIC;
694
+ REVOKE ALL ON TABLE fetchmail FROM postgres;
695
+ GRANT ALL ON TABLE fetchmail TO postgres;
696
+
697
+
698
+ --
699
+ -- Name: log; Type: ACL; Schema: public; Owner: postgres
700
+ --
701
+
702
+ REVOKE ALL ON TABLE log FROM PUBLIC;
703
+ REVOKE ALL ON TABLE log FROM postgres;
704
+ GRANT ALL ON TABLE log TO postgres;
705
+
706
+
707
+ --
708
+ -- Name: mailbox; Type: ACL; Schema: public; Owner: postgres
709
+ --
710
+
711
+ REVOKE ALL ON TABLE mailbox FROM PUBLIC;
712
+ REVOKE ALL ON TABLE mailbox FROM postgres;
713
+ GRANT ALL ON TABLE mailbox TO postgres;
714
+
715
+
716
+ --
717
+ -- Name: vacation; Type: ACL; Schema: public; Owner: postgres
718
+ --
719
+
720
+ REVOKE ALL ON TABLE vacation FROM PUBLIC;
721
+ REVOKE ALL ON TABLE vacation FROM postgres;
722
+ GRANT ALL ON TABLE vacation TO postgres;
723
+
724
+
725
+ --
726
+ -- Name: vacation_notification; Type: ACL; Schema: public; Owner: postgres
727
+ --
728
+
729
+ REVOKE ALL ON TABLE vacation_notification FROM PUBLIC;
730
+ REVOKE ALL ON TABLE vacation_notification FROM postgres;
731
+ GRANT ALL ON TABLE vacation_notification TO postgres;
732
+
733
+
734
+ --
735
+ -- PostgreSQL database dump complete
736
+ --
737
+