-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add invitation type column to support PS user invitation
[Re #1611] * The invitiation type is to distinguish which type of invitation it's. As of now we have one type of invitation in production which is "expert" and with PS we need another type of invitation. As experts have extra logic when the user actually accepts the invitation, the "INVITED" status is not enough. So this "type" column will give us the necessary information to distinguish both cases and more in the future.
- Loading branch information
1 parent
ee0f0be
commit a88f4cd
Showing
2 changed files
with
193 additions
and
0 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
backend/resources/migrations/195-add-invitation-type-enum.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
BEGIN; | ||
--;; | ||
CREATE TYPE INVITATION_TYPE AS ENUM('plastic-strategy', 'expert'); | ||
--;; | ||
COMMIT; |
188 changes: 188 additions & 0 deletions
188
backend/resources/migrations/196-setup-plastic-strategy-model.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
BEGIN; | ||
--;; | ||
CREATE TABLE plastic_strategy ( | ||
id SERIAL PRIMARY KEY, | ||
country_id INTEGER UNIQUE NOT NULL REFERENCES country (id), | ||
steps JSONB, | ||
created_at TIMESTAMP WITHOUT TIME ZONE DEFAULT NOW(), | ||
last_updated_at TIMESTAMP WITHOUT TIME ZONE | ||
); | ||
--;; | ||
CREATE TYPE plastic_strategy_team_type AS ENUM ( | ||
'steering-committee', | ||
'project-team' | ||
); | ||
--;; | ||
CREATE TYPE plastic_strategy_team_role AS ENUM ( | ||
'admin', | ||
'editor', | ||
'viewer' | ||
); | ||
--;; | ||
CREATE TABLE plastic_strategy_team_member ( | ||
plastic_strategy_id INTEGER NOT NULL REFERENCES plastic_strategy (id) ON DELETE CASCADE, | ||
user_id INTEGER NOT NULL REFERENCES stakeholder (id) ON DELETE CASCADE, | ||
teams PLASTIC_STRATEGY_TEAM_TYPE[] NOT NULL, | ||
role PLASTIC_STRATEGY_TEAM_ROLE NOT NULL, | ||
last_updated_at TIMESTAMP WITHOUT TIME ZONE, | ||
CONSTRAINT plastic_strategy_team_pkey PRIMARY KEY (plastic_strategy_id, user_id) | ||
); | ||
--;; | ||
CREATE TABLE plastic_strategy_initiative_bookmark ( | ||
plastic_strategy_id INTEGER NOT NULL REFERENCES plastic_strategy (id), | ||
initiative_id INTEGER NOT NULL REFERENCES initiative (id), | ||
CONSTRAINT plastic_strategy_initiative_bookmark_pkey PRIMARY KEY (plastic_strategy_id, initiative_id) | ||
); | ||
--;; | ||
CREATE TABLE plastic_strategy_case_study_bookmark ( | ||
plastic_strategy_id INTEGER NOT NULL REFERENCES plastic_strategy (id), | ||
case_study_id INTEGER NOT NULL REFERENCES case_study (id), | ||
CONSTRAINT plastic_strategy_case_study_bookmark_pkey PRIMARY KEY (plastic_strategy_id, case_study_id) | ||
); | ||
--;; | ||
CREATE TABLE plastic_strategy_technology_bookmark ( | ||
plastic_strategy_id INTEGER NOT NULL REFERENCES plastic_strategy (id), | ||
technology_id INTEGER NOT NULL REFERENCES technology (id), | ||
CONSTRAINT plastic_strategy_technology_bookmark_pkey PRIMARY KEY (plastic_strategy_id, technology_id) | ||
); | ||
--;; | ||
CREATE TABLE plastic_strategy_policy_bookmark ( | ||
plastic_strategy_id INTEGER NOT NULL REFERENCES plastic_strategy (id), | ||
policy_id INTEGER NOT NULL REFERENCES POLICY (id), CONSTRAINT plastic_strategy_policy_bookmark_pkey PRIMARY KEY (plastic_strategy_id, policy_id)); | ||
--;; | ||
CREATE TABLE plastic_strategy_event_bookmark ( | ||
plastic_strategy_id INTEGER NOT NULL REFERENCES plastic_strategy (id), | ||
event_id INTEGER NOT NULL REFERENCES event (id), | ||
CONSTRAINT plastic_strategy_event_bookmark_pkey PRIMARY KEY (plastic_strategy_id, event_id) | ||
); | ||
--;; | ||
CREATE TABLE plastic_strategy_resource_bookmark ( | ||
plastic_strategy_id INTEGER NOT NULL REFERENCES plastic_strategy (id), | ||
resource_id INTEGER NOT NULL REFERENCES resource (id), | ||
CONSTRAINT plastic_strategy_resource_bookmark_pkey PRIMARY KEY (plastic_strategy_id, resource_id) | ||
); | ||
--;; | ||
CREATE TABLE plastic_strategy_organisation_bookmark ( | ||
plastic_strategy_id INTEGER NOT NULL REFERENCES plastic_strategy (id), | ||
organisation_id INTEGER NOT NULL REFERENCES organisation (id), | ||
CONSTRAINT plastic_strategy_organisation_bookmark_pkey PRIMARY KEY (plastic_strategy_id, organisation_id) | ||
); | ||
--;; | ||
INSERT INTO rbac_context_type ( | ||
name, | ||
description) | ||
VALUES ( | ||
'plastic-strategy', | ||
'Plastic strategy-level context type'); | ||
--;; | ||
INSERT INTO rbac_permission ( | ||
id, | ||
name, | ||
description, | ||
context_type_name) | ||
VALUES ( | ||
'd7bb3d25-e8b7-4311-a6a1-c96855b35081', | ||
'application/list-plastic-strategies', | ||
'Allows listing plastic strategies', | ||
'application'), | ||
( | ||
'7298e9b0-8632-475b-b116-7ab26969d1a0', | ||
'plastic-strategy/read', | ||
'Allows viewing a plastic strategy', | ||
'plastic-strategy'), | ||
( | ||
'b0e1db85-96d7-440f-a374-fd76f4088cb3', | ||
'plastic-strategy/bookmark', | ||
'Allows bookmarking platform resource for a plastic strategy', | ||
'plastic-strategy'), | ||
( | ||
'4a841fba-ebb1-41a8-85d8-b02e77708e8e', | ||
'plastic-strategy/update-step', | ||
'Allows editing a step', | ||
'plastic-strategy'), | ||
( | ||
'fe3afc8c-5db6-4ab6-9223-f74a9fee906e', | ||
'plastic-strategy/add-team-member', | ||
'Allows adding a plastic strategy team member', | ||
'plastic-strategy'), | ||
( | ||
'2777657c-5779-4960-81eb-d08efbd28fde', | ||
'plastic-strategy/update-team-member', | ||
'Allows editing a plastic strategy team member', | ||
'plastic-strategy'); | ||
--;; | ||
INSERT INTO rbac_role ( | ||
id, | ||
name, | ||
description) | ||
VALUES ( | ||
'5422d5a9-89b4-494d-97a1-894657047803', | ||
'plastic-strategy-admin', | ||
'Plastic strategy admin'), | ||
( | ||
'982889c1-368c-489c-b8f4-234802e0781d', | ||
'plastic-strategy-editor', | ||
'Plastic strategy editor'), | ||
( | ||
'4c953c83-bc6e-41a0-bde7-d25a6a938a3c', | ||
'plastic-strategy-viewer', | ||
'Plastic strategy viewer'); | ||
--;; | ||
INSERT INTO rbac_role_permission ( | ||
role_id, | ||
permission_id, | ||
permission_value) | ||
VALUES ( | ||
'5422d5a9-89b4-494d-97a1-894657047803', | ||
'd7bb3d25-e8b7-4311-a6a1-c96855b35081', | ||
1), | ||
( | ||
'5422d5a9-89b4-494d-97a1-894657047803', | ||
'7298e9b0-8632-475b-b116-7ab26969d1a0', | ||
1), | ||
( | ||
'5422d5a9-89b4-494d-97a1-894657047803', | ||
'b0e1db85-96d7-440f-a374-fd76f4088cb3', | ||
1), | ||
( | ||
'5422d5a9-89b4-494d-97a1-894657047803', | ||
'4a841fba-ebb1-41a8-85d8-b02e77708e8e', | ||
1), | ||
( | ||
'5422d5a9-89b4-494d-97a1-894657047803', | ||
'fe3afc8c-5db6-4ab6-9223-f74a9fee906e', | ||
1), | ||
( | ||
'5422d5a9-89b4-494d-97a1-894657047803', | ||
'2777657c-5779-4960-81eb-d08efbd28fde', | ||
1), | ||
( | ||
'982889c1-368c-489c-b8f4-234802e0781d', | ||
'd7bb3d25-e8b7-4311-a6a1-c96855b35081', | ||
1), | ||
( | ||
'982889c1-368c-489c-b8f4-234802e0781d', | ||
'7298e9b0-8632-475b-b116-7ab26969d1a0', | ||
1), | ||
( | ||
'982889c1-368c-489c-b8f4-234802e0781d', | ||
'b0e1db85-96d7-440f-a374-fd76f4088cb3', | ||
1), | ||
( | ||
'982889c1-368c-489c-b8f4-234802e0781d', | ||
'4a841fba-ebb1-41a8-85d8-b02e77708e8e', | ||
1), | ||
( | ||
'4c953c83-bc6e-41a0-bde7-d25a6a938a3c', | ||
'7298e9b0-8632-475b-b116-7ab26969d1a0', | ||
1); | ||
--;; | ||
ALTER TABLE invitation | ||
ADD COLUMN type INVITATION_TYPE; | ||
--;; | ||
UPDATE invitation SET type = 'expert'; | ||
--;; | ||
ALTER TABLE invitation | ||
ALTER COLUMN type SET NOT NULL; | ||
--;; | ||
COMMIT; |