3a5fcfc2fc6765c262ee484c012c9398379649bc
[minimedit.git] / widget / comments.sql
1 CREATE TABLE issues (
2         page       text        NOT NULL DEFAULT 'issue',
3         link       text,
4         subject    text,
5         body       text,
6         created    timestamptz          DEFAULT now(),
7         closed     timestamptz,
8         updated    timestamptz NOT NULL DEFAULT now(),
9         author     text,
10         assign     text,
11         id         serial      NOT NULL PRIMARY KEY
12 );
13
14 CREATE TABLE comments (
15         page       text,
16         message    text,
17         created    timestamptz DEFAULT now(),
18         author     text,
19         id         serial      NOT NULL PRIMARY KEY
20 );
21
22 CREATE TABLE journal (
23         comment_id integer     NOT NULL REFERENCES comments (id),
24         property   text        NOT NULL DEFAULT 'attr',
25         col        text        NOT NULL,
26         old_value  text,
27         value      text,
28         id         serial      NOT NULL PRIMARY KEY
29 );
30
31 CREATE OR REPLACE VIEW messages AS (
32         SELECT *, regexp_replace(page, '.*/', '')::int issue FROM comments
33                 UNION ALL
34         SELECT concat(page,'/',id), body, created, author, NULL, id FROM issues
35 );