chiark / gitweb /
Store Unix timestamps in the database, rather than SQL ones.
[odin-cgi] / sql / setup-pastebin.sql
... / ...
CommitLineData
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
10begin;
11
12drop table if exists odin_pastebin;
13drop table if exists odin_pastebin_lang;
14drop table if exists odin_pastebin_seq;
15
16create table odin_pastebin_lang
17 (lang varchar(32) primary key,
18 descr varchar(64) not null);
19insert into odin_pastebin_lang (lang, descr) values ('txt', 'Plain text');
20
21create table odin_pastebin_seq (seq int);
22insert into odin_pastebin_seq (seq) values (10000);
23
24create 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);
37create index odin_pastebin_by_lang on odin_pastebin (lang);
38create index odin_pastebin_by_owner on odin_pastebin (owner);
39
40commit;