chiark / gitweb /
New things for a mail redirection service, with randomized local parts.
[odin-cgi] / sql / setup-mail.sql
CommitLineData
c86aee46
MW
1/* -*-sql-*-
2 *
3 * Plain old SQL for setting up the tables for Odin mail redirection.
4 */
5
6/* The various tools assume that the database is appropriate configured with
7 * the SERIALIZABLE isolation level.
8 */
9
10begin;
11
12drop view if exists odin_maildeliver;
13drop table if exists odin_mailredir;
14
15create table odin_mailredir
16 (lpart varchar(64) not null,
17 dom varchar(128) not null,
18 owner varchar(64) not null,
19 recip text not null default '',
20 expire bigint not null,
21 st varchar(16) not null default 'live',
22 comment text not null default '',
23 primary key (lpart, dom));
24create index odin_mailredir_by_owner_st on odin_mailredir (owner, st);
25create index odin_mailredir_by_expire_st on odin_mailredir (expire, st);
26create index odin_mailredir_by_recip on odin_mailredir (recip);
27
28create view odin_maildeliver as
29 select lpart, dom, recip from odin_mailredir
30 where st = 'live' and
31 (expire = -1 or
32 expire > extract(epoch from current_timestamp));
33
34commit;