Commit | Line | Data |
---|---|---|
be24e9af MW |
1 | /* -*-sql-*- |
2 | * | |
3 | * Plain old SQL for setting up the tables for Odin web services. | |
128543b0 MW |
4 | * |
5 | * (c) 2015 Mark Wooding | |
6 | */ | |
7 | ||
8 | /*----- Licensing notice ---------------------------------------------------- | |
9 | * | |
10 | * This file is part of the `odin.gg' service, `odin-cgi'. | |
11 | * | |
12 | * `odin-cgi' is free software; you can redistribute it and/or modify | |
13 | * it under the terms of the GNU Affero General Public License as | |
14 | * published by the Free Software Foundation; either version 3 of the | |
15 | * License, or (at your option) any later version. | |
16 | * | |
17 | * `odin-cgi' is distributed in the hope that it will be useful, | |
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 | * GNU Affero General Public License for more details. | |
21 | * | |
22 | * You should have received a copy of the GNU Affero General Public | |
23 | * License along with `odin-cgi'; if not, see | |
24 | * <http://www.gnu.org/licenses/>. | |
be24e9af MW |
25 | */ |
26 | ||
27 | /* The various tools assume that the database is appropriate configured with | |
28 | * the SERIALIZABLE isolation level. | |
29 | */ | |
30 | ||
31 | begin; | |
32 | ||
33 | drop table if exists odin_pastebin; | |
34 | drop table if exists odin_pastebin_lang; | |
35 | drop table if exists odin_pastebin_seq; | |
36 | ||
37 | create table odin_pastebin_lang | |
4d553a60 | 38 | (lang varchar(32) primary key, |
be24e9af MW |
39 | descr varchar(64) not null); |
40 | insert into odin_pastebin_lang (lang, descr) values ('txt', 'Plain text'); | |
41 | ||
42 | create table odin_pastebin_seq (seq int); | |
43 | insert into odin_pastebin_seq (seq) values (10000); | |
44 | ||
45 | create table odin_pastebin | |
46 | (tag varchar(16) primary key, | |
3300e9a2 | 47 | stamp bigint not null, |
be24e9af MW |
48 | edithash varchar(128) not null, |
49 | owner varchar(64) not null, | |
50 | title varchar(128) not null, | |
51 | lang varchar(32) not null | |
97a33b9c | 52 | default 'txt' |
be24e9af MW |
53 | references odin_pastebin_lang (lang) |
54 | on update cascade | |
55 | on delete set default | |
56 | deferrable initially deferred, | |
57 | content text not null); | |
58 | create index odin_pastebin_by_lang on odin_pastebin (lang); | |
59 | create index odin_pastebin_by_owner on odin_pastebin (owner); | |
60 | ||
61 | commit; |