
jbe@17: BEGIN;
jbe@17: 
jbe@17: CREATE OR REPLACE VIEW "liquid_feedback_version" AS
jbe@17:   SELECT * FROM (VALUES ('beta18', NULL, NULL, NULL))
jbe@17:   AS "subquery"("string", "major", "minor", "revision");
jbe@17: 
jbe@17: CREATE OR REPLACE VIEW "timeline_issue" AS
jbe@17:     SELECT
jbe@17:       "created" AS "occurrence",
jbe@17:       'issue_created'::"timeline_event" AS "event",
jbe@17:       "id" AS "issue_id"
jbe@17:     FROM "issue"
jbe@17:   UNION ALL
jbe@17:     SELECT
jbe@17:       "closed" AS "occurrence",
jbe@17:       'issue_canceled'::"timeline_event" AS "event",
jbe@17:       "id" AS "issue_id"
jbe@17:     FROM "issue" WHERE "closed" NOTNULL AND "fully_frozen" ISNULL
jbe@17:   UNION ALL
jbe@17:     SELECT
jbe@17:       "accepted" AS "occurrence",
jbe@17:       'issue_accepted'::"timeline_event" AS "event",
jbe@17:       "id" AS "issue_id"
jbe@17:     FROM "issue" WHERE "accepted" NOTNULL
jbe@17:   UNION ALL
jbe@17:     SELECT
jbe@17:       "half_frozen" AS "occurrence",
jbe@17:       'issue_half_frozen'::"timeline_event" AS "event",
jbe@17:       "id" AS "issue_id"
jbe@17:     FROM "issue" WHERE "half_frozen" NOTNULL
jbe@17:   UNION ALL
jbe@17:     SELECT
jbe@17:       "fully_frozen" AS "occurrence",
jbe@17:       'issue_voting_started'::"timeline_event" AS "event",
jbe@17:       "id" AS "issue_id"
jbe@17:     FROM "issue"
jbe@17:     WHERE "fully_frozen" NOTNULL
jbe@17:     AND ("closed" ISNULL OR "closed" != "fully_frozen")
jbe@17:   UNION ALL
jbe@17:     SELECT
jbe@17:       "closed" AS "occurrence",
jbe@17:       CASE WHEN "fully_frozen" = "closed" THEN
jbe@17:         'issue_finished_without_voting'::"timeline_event"
jbe@17:       ELSE
jbe@17:         'issue_finished_after_voting'::"timeline_event"
jbe@17:       END AS "event",
jbe@17:       "id" AS "issue_id"
jbe@17:     FROM "issue" WHERE "closed" NOTNULL AND "fully_frozen" NOTNULL;
jbe@17: 
jbe@17: COMMIT;




