liquid_feedback_core
view update/core-update.v2.2.4-v2.2.5.sql @ 547:3cde0bb68adf
Use unit/area/policy_updated event instead of unit/area/policy_removed
| author | jbe | 
|---|---|
| date | Tue Jul 18 12:28:45 2017 +0200 (2017-07-18) | 
| parents | 992ec266356d | 
| children | 
 line source
     1 -- NOTICE: This update script requires PostgreSQL version 9.1 or higher.
     2 --         If you use an older version, please dump your database and
     3 --         update it on a system with PostgreSQL 9.1 or higher, before
     4 --         restoring it on your original system.
     6 -- NOTICE: The following command cannot be executed within a transaction block
     7 --         and must be rolled back manually, if the update fails:
     8 ALTER TYPE "issue_state" ADD VALUE 'canceled_by_admin' AFTER 'voting';
    10 BEGIN;
    12 CREATE OR REPLACE VIEW "liquid_feedback_version" AS
    13   SELECT * FROM (VALUES ('2.2.5', 2, 2, 5))
    14   AS "subquery"("string", "major", "minor", "revision");
    16 ALTER TABLE "issue" ADD COLUMN "admin_notice" TEXT;
    17 COMMENT ON COLUMN "issue"."admin_notice" IS 'Public notice by admin to explain manual interventions, or to announce corrections';
    19 ALTER TABLE "issue" DROP CONSTRAINT "valid_state";
    20 ALTER TABLE "issue" ADD
    21         CONSTRAINT "valid_state" CHECK (
    22           (
    23             ("accepted" ISNULL  AND "half_frozen" ISNULL  AND "fully_frozen" ISNULL ) OR
    24             ("accepted" NOTNULL AND "half_frozen" ISNULL  AND "fully_frozen" ISNULL ) OR
    25             ("accepted" NOTNULL AND "half_frozen" NOTNULL AND "fully_frozen" ISNULL ) OR
    26             ("accepted" NOTNULL AND "half_frozen" NOTNULL AND "fully_frozen" NOTNULL)
    27           ) AND (
    28             ("state" = 'admission'    AND "closed" ISNULL AND "accepted" ISNULL) OR
    29             ("state" = 'discussion'   AND "closed" ISNULL AND "accepted" NOTNULL AND "half_frozen" ISNULL) OR
    30             ("state" = 'verification' AND "closed" ISNULL AND "half_frozen" NOTNULL AND "fully_frozen" ISNULL) OR
    31             ("state" = 'voting'       AND "closed" ISNULL AND "fully_frozen" NOTNULL) OR
    32             ("state" = 'canceled_by_admin' AND "closed" NOTNULL) OR
    33             ("state" = 'canceled_revoked_before_accepted'              AND "closed" NOTNULL AND "accepted" ISNULL) OR
    34             ("state" = 'canceled_issue_not_accepted'                   AND "closed" NOTNULL AND "accepted" ISNULL) OR
    35             ("state" = 'canceled_after_revocation_during_discussion'   AND "closed" NOTNULL AND "half_frozen"  ISNULL) OR
    36             ("state" = 'canceled_after_revocation_during_verification' AND "closed" NOTNULL AND "fully_frozen" ISNULL) OR
    37             ("state" = 'canceled_no_initiative_admitted' AND "closed" NOTNULL AND "fully_frozen" NOTNULL AND "closed" = "fully_frozen") OR
    38             ("state" = 'finished_without_winner'         AND "closed" NOTNULL AND "fully_frozen" NOTNULL AND "closed" != "fully_frozen") OR
    39             ("state" = 'finished_with_winner'            AND "closed" NOTNULL AND "fully_frozen" NOTNULL AND "closed" != "fully_frozen")
    40           ));
    42 COMMENT ON TABLE "direct_population_snapshot" IS 'Snapshot of active members having either a "membership" in the "area" or an "interest" in the "issue"; for corrections refer to column "issue_notice" of "issue" table';
    43 COMMENT ON TABLE "direct_population_snapshot" IS 'Delegations increasing the weight of entries in the "direct_population_snapshot" table; for corrections refer to column "issue_notice" of "issue" table';
    44 COMMENT ON TABLE "direct_interest_snapshot" IS 'Snapshot of active members having an "interest" in the "issue"; for corrections refer to column "issue_notice" of "issue" table';
    45 COMMENT ON TABLE "delegating_interest_snapshot" IS 'Delegations increasing the weight of entries in the "direct_interest_snapshot" table; for corrections refer to column "issue_notice" of "issue" table';
    46 COMMENT ON TABLE "direct_supporter_snapshot" IS 'Snapshot of supporters of initiatives (weight is stored in "direct_interest_snapshot"); for corrections refer to column "issue_notice" of "issue" table';
    47 COMMENT ON TABLE "direct_voter" IS 'Members having directly voted for/against initiatives of an issue; frontends must ensure that no voters are added or removed to/from this table when the issue has been closed; for corrections refer to column "issue_notice" of "issue" table';
    48 COMMENT ON TABLE "delegating_voter" IS 'Delegations increasing the weight of entries in the "direct_voter" table; for corrections refer to column "issue_notice" of "issue" table';
    49 COMMENT ON TABLE "vote" IS 'Manual and delegated votes without abstentions; frontends must ensure that no votes are added modified or removed when the issue has been closed; for corrections refer to column "issue_notice" of "issue" table';
    51 COMMIT;
