| 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_shorturl; |
| 13 | drop table if exists odin_shorturl_seq; |
| 14 | |
| 15 | create table odin_shorturl_seq (seq int); |
| 16 | insert into odin_shorturl_seq (seq) values (10000); |
| 17 | |
| 18 | create table odin_shorturl |
| 19 | (tag varchar(16) primary key, |
| 20 | stamp bigint not null, |
| 21 | owner varchar(64) not null, |
| 22 | url text not null); |
| 23 | create index odin_shorturl_by_owner on odin_shorturl (owner); |
| 24 | create index odin_shorturl_by_url_owner on odin_shorturl (url, owner); |
| 25 | |
| 26 | commit; |