doclist: link directory index pages
[minimedit.git] / widget / comments.sql
index 8a0655826101a8147c5e3e26984008285fe60a1f..a1520793c06a2ff121f3b7bb8e9304e64e466c00 100644 (file)
@@ -4,7 +4,7 @@ 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,
@@ -13,8 +13,24 @@ CREATE TABLE issues (
 
 CREATE TABLE comments (
        page       text,
+       raw        text,
        message    text,
        created    timestamptz DEFAULT now(),
        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
+);