summaryrefslogtreecommitdiff
path: root/server/pracro.psql
blob: 34283d065cb10fcc25389525e05eb8b8c1eb4708 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
-- vim: syn=sql
-- As root:
-- #createuser -P -h localhost -U postgres
-- #createdb -U postgres -h localhost pracro

-- DROP DATABASE IF EXISTS pracro;
-- CREATE DATABASE pracro WITH OWNER = pracro ENCODING = 'UNICODE' TABLESPACE = pg_default;

-- DROP SEQUENCE IF EXISTS transeq;
-- CREATE SEQUENCE transeq;

DROP TABLE IF EXISTS transactions;
CREATE TABLE transactions
(
  -- "uid"       bigint PRIMARY KEY,
  "cpr"       varchar(11),
  "macro"     text,
  "version"   text,
  "timestamp" bigint,
  "user"      text
) WITH OIDS;
ALTER TABLE transactions OWNER TO pracro;
CREATE INDEX x_transactions_cpr_timestamp ON transactions("cpr", "timestamp");


DROP TABLE IF EXISTS fieldnames;
CREATE TABLE fieldnames
(
  "name"        text PRIMARY KEY,
  "description" text,
  "timestamp"   bigint
) WITH OIDS;
ALTER TABLE fieldnames OWNER TO pracro;


DROP TABLE IF EXISTS fields;
CREATE TABLE fields
(
  "transaction" bigint,
  "name"        text,
  "value"       text
) WITH OIDS;
ALTER TABLE fields OWNER TO pracro;
-- ALTER TABLE fields ADD CONSTRAINT cx_fields_transactions FOREIGN KEY ("transaction") REFERENCES transactions("uid");
-- ALTER TABLE fields ADD CONSTRAINT cx_fields_name FOREIGN KEY ("name") REFERENCES fieldnames("name");


DROP TABLE IF EXISTS journal;
CREATE TABLE journal
(
  "cpr"       varchar(11),
  "macro"     text,
  "version"   text,
  "timestamp" bigint,
  "user"      text,
  "journal"   text
) WITH OIDS;
ALTER TABLE journal OWNER TO pracro;
CREATE INDEX x_journal_cpr_timestamp ON journal("cpr", "timestamp");