Commit | Line | Data |
---|---|---|
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 | ||
10 | begin; | |
11 | ||
12 | drop view if exists odin_maildeliver; | |
13 | drop table if exists odin_mailredir; | |
14 | ||
15 | create 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)); | |
24 | create index odin_mailredir_by_owner_st on odin_mailredir (owner, st); | |
25 | create index odin_mailredir_by_expire_st on odin_mailredir (expire, st); | |
26 | create index odin_mailredir_by_recip on odin_mailredir (recip); | |
27 | ||
28 | create 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 | ||
34 | commit; |