b805a2a33a6fdd89082ddebf6889560b4cffbd34
[minimedit.git] / widget / comments.sql
1 CREATE TABLE issues (
2         page       text        NOT NULL DEFAULT 'issue',
3         link       text,
4         subject    text,
5         created    timestamptz          DEFAULT now(),
6         closed     timestamptz,
7         updated    timestamptz NOT NULL DEFAULT now(),
8         author     text,
9         assign     text,
10         id         serial      NOT NULL PRIMARY KEY
11 );
12
13 CREATE TABLE comments (
14         page       text,
15         raw        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 );