issue/report: activity widget to list latest messages
[minimedit.git] / widget / comments.sql
index 5e33716da32f7843e95e441c797e0ee36fb9543c..3a5fcfc2fc6765c262ee484c012c9398379649bc 100644 (file)
@@ -4,8 +4,10 @@ CREATE TABLE issues (
        subject    text,
        body       text,
        created    timestamptz          DEFAULT now(),
-       closed     timestamptz          DEFAULT now(),
+       closed     timestamptz,
+       updated    timestamptz NOT NULL DEFAULT now(),
        author     text,
+       assign     text,
        id         serial      NOT NULL PRIMARY KEY
 );
 
@@ -16,3 +18,18 @@ CREATE TABLE comments (
        author     text,
        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
+               UNION ALL
+       SELECT concat(page,'/',id), body, created, author, NULL, id FROM issues
+);