chiark / gitweb /
Allow users to give away local parts to other users.
[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,
c68a5549 19 creator varchar(64) not null,
c86aee46
MW
20 recip text not null default '',
21 expire bigint not null,
22 st varchar(16) not null default 'live',
23 comment text not null default '',
24 primary key (lpart, dom));
25create index odin_mailredir_by_owner_st on odin_mailredir (owner, st);
26create index odin_mailredir_by_expire_st on odin_mailredir (expire, st);
27create index odin_mailredir_by_recip on odin_mailredir (recip);
28
29create view odin_maildeliver as
30 select lpart, dom, recip from odin_mailredir
31 where st = 'live' and
32 (expire = -1 or
33 expire > extract(epoch from current_timestamp));
34
35commit;