liquid_feedback_core

view update/core-update.v4.0.0-v4.1.0.sql @ 593:e7f772ca0621

Removed an index on table "initiative"
author jbe
date Sat Dec 08 01:37:23 2018 +0100 (20 months ago)
parents f9e09710ec60
children
line source
1 BEGIN;
3 CREATE OR REPLACE VIEW "liquid_feedback_version" AS
4 SELECT * FROM (VALUES ('4.1.0', 4, 1, 0))
5 AS "subquery"("string", "major", "minor", "revision");
7 ALTER TABLE "member" ADD COLUMN "unsubscribe_secret" TEXT;
9 COMMENT ON COLUMN "member"."unsubscribe_secret" IS 'Secret string to be used for a List-Unsubscribe mail header';
11 ALTER TABLE "member" ADD COLUMN "role" BOOLEAN NOT NULL DEFAULT FALSE;
13 CREATE TABLE "agent" (
14 PRIMARY KEY ("controlled_id", "controller_id"),
15 "controlled_id" INT4 REFERENCES "member" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
16 "controller_id" INT4 REFERENCES "member" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
17 "accepted" BOOLEAN,
18 CONSTRAINT "controlled_id_and_controller_id_differ" CHECK (
19 "controlled_id" != "controller_id" ) );
20 CREATE INDEX "agent_controller_id_idx" ON "agent" ("controller_id");
22 COMMENT ON TABLE "agent" IS 'Privileges for role accounts';
24 COMMENT ON COLUMN "agent"."accepted" IS 'If "accepted" is NULL, then the member was invited to be an agent, but has not reacted yet. If it is TRUE, the member has accepted the invitation, if it is FALSE, the member has rejected the invitation.';
26 ALTER TABLE "session" ADD COLUMN "real_member_id" INT4 REFERENCES "member" ("id") ON DELETE RESTRICT ON UPDATE CASCADE;
28 COMMENT ON COLUMN "session"."member_id" IS 'Reference to member, who is logged in, or role account in use';
29 COMMENT ON COLUMN "session"."real_member_id" IS 'Reference to member, who is really logged in (real person rather than role account)';
31 CREATE TABLE "role_verification" (
32 "id" SERIAL8 PRIMARY KEY,
33 "requested" TIMESTAMPTZ,
34 "request_origin" JSONB,
35 "request_data" JSONB,
36 "requesting_member_id" INT4 REFERENCES "member" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
37 "requesting_real_member_id" INT4 REFERENCES "member" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
38 "verifying_member_id" INT4 REFERENCES "member" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
39 "verified_member_id" INT4 REFERENCES "member" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
40 "verified" TIMESTAMPTZ,
41 "verification_data" JSONB,
42 "denied" TIMESTAMPTZ,
43 "comment" TEXT,
44 CONSTRAINT "verified_and_denied_conflict" CHECK (
45 "verified" ISNULL OR "denied" ISNULL ) );
46 CREATE INDEX "role_verification_requested_idx" ON "role_verification" ("requested");
47 CREATE INDEX "role_verification_open_request_idx" ON "role_verification" ("requested") WHERE "verified" ISNULL AND "denied" ISNULL;
48 CREATE INDEX "role_verification_requesting_member_id_idx" ON "role_verification" ("requesting_member_id");
49 CREATE INDEX "role_verification_verified_member_id_idx" ON "role_verification" ("verified_member_id");
50 CREATE INDEX "role_verification_verified_idx" ON "role_verification" ("verified");
51 CREATE INDEX "role_verification_denied_idx" ON "role_verification" ("denied");
53 COMMENT ON TABLE "role_verification" IS 'Request to verify a role account (see table "verification" for documentation of columns not documented for this table)';
55 COMMENT ON COLUMN "role_verification"."requesting_member_id" IS 'Member role account to verify';
56 COMMENT ON COLUMN "role_verification"."requesting_real_member_id" IS 'Member account of real person who requested verification';
58 ALTER TABLE "ignored_area" DROP CONSTRAINT "ignored_area_member_id_fkey";
59 ALTER TABLE "ignored_area" ADD FOREIGN KEY ("member_id") REFERENCES "member" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
61 CREATE OR REPLACE VIEW "expired_token" AS
62 SELECT * FROM "token" WHERE now() > "expiry" AND NOT (
63 "token_type" = 'authorization' AND "used" AND EXISTS (
64 SELECT NULL FROM "token" AS "other"
65 WHERE "other"."authorization_token_id" = "token"."id" ) );
67 ALTER TABLE "system_application" RENAME COLUMN "discovery_baseurl" TO "base_url";
68 ALTER TABLE "system_application" ADD COLUMN "manifest_url" TEXT;
70 COMMENT ON COLUMN "system_application"."base_url" IS 'Base URL for users';
71 COMMENT ON COLUMN "system_application"."manifest_url" IS 'URL referring to a manifest that can be used for application (type/version) discovery';
73 CREATE OR REPLACE FUNCTION "write_event_initiative_revoked_trigger"()
74 RETURNS TRIGGER
75 LANGUAGE 'plpgsql' VOLATILE AS $$
76 DECLARE
77 "issue_row" "issue"%ROWTYPE;
78 "area_row" "area"%ROWTYPE;
79 "draft_id_v" "draft"."id"%TYPE;
80 BEGIN
81 IF OLD."revoked" ISNULL AND NEW."revoked" NOTNULL THEN
82 -- NOTE: lock for primary key update to avoid new drafts
83 PERFORM NULL FROM "initiative" WHERE "id" = NEW."id" FOR UPDATE;
84 SELECT * INTO "issue_row" FROM "issue"
85 WHERE "id" = NEW."issue_id" FOR SHARE;
86 SELECT * INTO "area_row" FROM "area"
87 WHERE "id" = "issue_row"."area_id" FOR SHARE;
88 -- NOTE: FOR SHARE cannot be used with DISTINCT in view "current_draft"
89 PERFORM NULL FROM "draft" WHERE "initiative_id" = NEW."id" FOR SHARE;
90 SELECT "id" INTO "draft_id_v" FROM "current_draft"
91 WHERE "initiative_id" = NEW."id";
92 INSERT INTO "event" (
93 "event", "member_id",
94 "unit_id", "area_id", "policy_id", "issue_id", "state",
95 "initiative_id", "draft_id"
96 ) VALUES (
97 'initiative_revoked', NEW."revoked_by_member_id",
98 "area_row"."unit_id", "issue_row"."area_id",
99 "issue_row"."policy_id",
100 NEW."issue_id", "issue_row"."state",
101 NEW."id", "draft_id_v"
102 );
103 END IF;
104 RETURN NULL;
105 END;
106 $$;
108 COMMIT;

Impressum / About Us