391f8be96fa7a3dcd2980dca7ac5a5a1e48e394f
[odin-cgi] / sql / setup-pastebin.sql
1 /* -*-sql-*-
2 *
3 * Plain old SQL for setting up the tables for Odin web services.
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 table if exists odin_pastebin;
13 drop table if exists odin_pastebin_lang;
14 drop table if exists odin_pastebin_seq;
15
16 create table odin_pastebin_lang
17 (lang varchar(32) primary key,
18 descr varchar(64) not null);
19 insert into odin_pastebin_lang (lang, descr) values ('txt', 'Plain text');
20
21 create table odin_pastebin_seq (seq int);
22 insert into odin_pastebin_seq (seq) values (10000);
23
24 create table odin_pastebin
25 (tag varchar(16) primary key,
26 stamp bigint not null,
27 edithash varchar(128) not null,
28 owner varchar(64) not null,
29 title varchar(128) not null,
30 lang varchar(32) not null
31 default 'txt'
32 references odin_pastebin_lang (lang)
33 on update cascade
34 on delete set default
35 deferrable initially deferred,
36 content text not null);
37 create index odin_pastebin_by_lang on odin_pastebin (lang);
38 create index odin_pastebin_by_owner on odin_pastebin (owner);
39
40 commit;