chiark / gitweb /
Store Unix timestamps in the database, rather than SQL ones.
[odin-cgi] / sql / setup-pastebin.sql
CommitLineData
be24e9af
MW
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
4d553a60 17 (lang varchar(32) primary key,
be24e9af
MW
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,
3300e9a2 26 stamp bigint not null,
be24e9af
MW
27 edithash varchar(128) not null,
28 owner varchar(64) not null,
29 title varchar(128) not null,
30 lang varchar(32) not null
97a33b9c 31 default 'txt'
be24e9af
MW
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;