issue: store main description as comment row
[minimedit.git] / widget / comments.sql
index ff797445ff1f81631afd74855ce0a2c99ac24b90..b805a2a33a6fdd89082ddebf6889560b4cffbd34 100644 (file)
@@ -1,7 +1,33 @@
+CREATE TABLE issues (
+       page       text        NOT NULL DEFAULT 'issue',
+       link       text,
+       subject    text,
+       created    timestamptz          DEFAULT now(),
+       closed     timestamptz,
+       updated    timestamptz NOT NULL DEFAULT now(),
+       author     text,
+       assign     text,
+       id         serial      NOT NULL PRIMARY KEY
+);
+
 CREATE TABLE comments (
        page       text,
+       raw        text,
        message    text,
        created    timestamptz DEFAULT now(),
        author     text,
-       id         serial      PRIMARY KEY
+       id         serial      NOT NULL PRIMARY KEY
+);
+
+CREATE TABLE journal (
+       comment_id integer     NOT NULL REFERENCES comments (id),
+       property   text        NOT NULL DEFAULT 'attr',
+       col        text        NOT NULL,
+       old_value  text,
+       value      text,
+       id         serial      NOT NULL PRIMARY KEY
+);
+
+CREATE OR REPLACE VIEW messages AS (
+       SELECT *, regexp_replace(page, '.*/', '')::int issue FROM comments
 );