Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: permissions refactor, added create permissions #264

Merged
merged 10 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ tasks:
desc: runs and outputs results of created go tests with coverage
aliases: [cover]
cmds:
- go test -v ./... -coverprofile=coverage.out
- go test ./... -coverprofile=coverage.out

go:test:coverout:
desc: runs and outputs results of created go tests with coverage
Expand Down
39 changes: 39 additions & 0 deletions db/migrations-goose-postgres/20241203221236_creator_groups.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
-- +goose Up
-- create "organization_control_creators" table
CREATE TABLE "organization_control_creators" ("organization_id" character varying NOT NULL, "group_id" character varying NOT NULL, PRIMARY KEY ("organization_id", "group_id"), CONSTRAINT "organization_control_creators_group_id" FOREIGN KEY ("group_id") REFERENCES "groups" ("id") ON UPDATE NO ACTION ON DELETE CASCADE, CONSTRAINT "organization_control_creators_organization_id" FOREIGN KEY ("organization_id") REFERENCES "organizations" ("id") ON UPDATE NO ACTION ON DELETE CASCADE);
-- create "organization_control_objective_creators" table
CREATE TABLE "organization_control_objective_creators" ("organization_id" character varying NOT NULL, "group_id" character varying NOT NULL, PRIMARY KEY ("organization_id", "group_id"), CONSTRAINT "organization_control_objective_creators_group_id" FOREIGN KEY ("group_id") REFERENCES "groups" ("id") ON UPDATE NO ACTION ON DELETE CASCADE, CONSTRAINT "organization_control_objective_creators_organization_id" FOREIGN KEY ("organization_id") REFERENCES "organizations" ("id") ON UPDATE NO ACTION ON DELETE CASCADE);
-- create "organization_group_creators" table
CREATE TABLE "organization_group_creators" ("organization_id" character varying NOT NULL, "group_id" character varying NOT NULL, PRIMARY KEY ("organization_id", "group_id"), CONSTRAINT "organization_group_creators_group_id" FOREIGN KEY ("group_id") REFERENCES "groups" ("id") ON UPDATE NO ACTION ON DELETE CASCADE, CONSTRAINT "organization_group_creators_organization_id" FOREIGN KEY ("organization_id") REFERENCES "organizations" ("id") ON UPDATE NO ACTION ON DELETE CASCADE);
-- create "organization_internal_policy_creators" table
CREATE TABLE "organization_internal_policy_creators" ("organization_id" character varying NOT NULL, "group_id" character varying NOT NULL, PRIMARY KEY ("organization_id", "group_id"), CONSTRAINT "organization_internal_policy_creators_group_id" FOREIGN KEY ("group_id") REFERENCES "groups" ("id") ON UPDATE NO ACTION ON DELETE CASCADE, CONSTRAINT "organization_internal_policy_creators_organization_id" FOREIGN KEY ("organization_id") REFERENCES "organizations" ("id") ON UPDATE NO ACTION ON DELETE CASCADE);
-- create "organization_narrative_creators" table
CREATE TABLE "organization_narrative_creators" ("organization_id" character varying NOT NULL, "group_id" character varying NOT NULL, PRIMARY KEY ("organization_id", "group_id"), CONSTRAINT "organization_narrative_creators_group_id" FOREIGN KEY ("group_id") REFERENCES "groups" ("id") ON UPDATE NO ACTION ON DELETE CASCADE, CONSTRAINT "organization_narrative_creators_organization_id" FOREIGN KEY ("organization_id") REFERENCES "organizations" ("id") ON UPDATE NO ACTION ON DELETE CASCADE);
-- create "organization_procedure_creators" table
CREATE TABLE "organization_procedure_creators" ("organization_id" character varying NOT NULL, "group_id" character varying NOT NULL, PRIMARY KEY ("organization_id", "group_id"), CONSTRAINT "organization_procedure_creators_group_id" FOREIGN KEY ("group_id") REFERENCES "groups" ("id") ON UPDATE NO ACTION ON DELETE CASCADE, CONSTRAINT "organization_procedure_creators_organization_id" FOREIGN KEY ("organization_id") REFERENCES "organizations" ("id") ON UPDATE NO ACTION ON DELETE CASCADE);
-- create "organization_program_creators" table
CREATE TABLE "organization_program_creators" ("organization_id" character varying NOT NULL, "group_id" character varying NOT NULL, PRIMARY KEY ("organization_id", "group_id"), CONSTRAINT "organization_program_creators_group_id" FOREIGN KEY ("group_id") REFERENCES "groups" ("id") ON UPDATE NO ACTION ON DELETE CASCADE, CONSTRAINT "organization_program_creators_organization_id" FOREIGN KEY ("organization_id") REFERENCES "organizations" ("id") ON UPDATE NO ACTION ON DELETE CASCADE);
-- create "organization_risk_creators" table
CREATE TABLE "organization_risk_creators" ("organization_id" character varying NOT NULL, "group_id" character varying NOT NULL, PRIMARY KEY ("organization_id", "group_id"), CONSTRAINT "organization_risk_creators_group_id" FOREIGN KEY ("group_id") REFERENCES "groups" ("id") ON UPDATE NO ACTION ON DELETE CASCADE, CONSTRAINT "organization_risk_creators_organization_id" FOREIGN KEY ("organization_id") REFERENCES "organizations" ("id") ON UPDATE NO ACTION ON DELETE CASCADE);
-- create "organization_template_creators" table
CREATE TABLE "organization_template_creators" ("organization_id" character varying NOT NULL, "group_id" character varying NOT NULL, PRIMARY KEY ("organization_id", "group_id"), CONSTRAINT "organization_template_creators_group_id" FOREIGN KEY ("group_id") REFERENCES "groups" ("id") ON UPDATE NO ACTION ON DELETE CASCADE, CONSTRAINT "organization_template_creators_organization_id" FOREIGN KEY ("organization_id") REFERENCES "organizations" ("id") ON UPDATE NO ACTION ON DELETE CASCADE);

-- +goose Down
-- reverse: create "organization_template_creators" table
DROP TABLE "organization_template_creators";
-- reverse: create "organization_risk_creators" table
DROP TABLE "organization_risk_creators";
-- reverse: create "organization_program_creators" table
DROP TABLE "organization_program_creators";
-- reverse: create "organization_procedure_creators" table
DROP TABLE "organization_procedure_creators";
-- reverse: create "organization_narrative_creators" table
DROP TABLE "organization_narrative_creators";
-- reverse: create "organization_internal_policy_creators" table
DROP TABLE "organization_internal_policy_creators";
-- reverse: create "organization_group_creators" table
DROP TABLE "organization_group_creators";
-- reverse: create "organization_control_objective_creators" table
DROP TABLE "organization_control_objective_creators";
-- reverse: create "organization_control_creators" table
DROP TABLE "organization_control_creators";
3 changes: 2 additions & 1 deletion db/migrations-goose-postgres/atlas.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
h1:qB7pvZmMAZCgd2wU9skRYfsNWbGahD04hXhfqKkIIdE=
h1:SfiX3usnAeGxo5b5/Zjpdxqy60tmdM1shU0VI9Esi74=
20240827061503_init.sql h1:D0Ce7h0FSKpjtQOHZK5gXOpaPvlNAFHHzqfQQ8re0T4=
20241014185634_object_upload.sql h1:xeeCqYCpQ3RFWgNjnKV1GMHgTEoZK2aWv5a2EvU4DP8=
20241030173034_base.sql h1:+eJ3JGD5lzsP16mz7q+yD78Jvs7sTX8nBZQmS68hjoA=
Expand All @@ -11,3 +11,4 @@ h1:qB7pvZmMAZCgd2wU9skRYfsNWbGahD04hXhfqKkIIdE=
20241126203309_control_objectives.sql h1:wo56TBIY22BZwoGMetReVarOQKyEyiOCeLJolOJew38=
20241126232457_narratives.sql h1:i7t3h2BYDIR11xWdu4BfKbcZjO2OWx0ZG5glve4WBv8=
20241201194400_controls.sql h1:kRChIRC5+5qzcD8IXSIpp7dt1w/xvhBw7F0+YiEoFUc=
20241203221236_creator_groups.sql h1:NNAIP7ISaBf1HuZgPhkGnf8yfLrpps9QY+1UOdSTp3o=
18 changes: 18 additions & 0 deletions db/migrations/20241203221235_creator_groups.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-- Create "organization_control_creators" table
CREATE TABLE "organization_control_creators" ("organization_id" character varying NOT NULL, "group_id" character varying NOT NULL, PRIMARY KEY ("organization_id", "group_id"), CONSTRAINT "organization_control_creators_group_id" FOREIGN KEY ("group_id") REFERENCES "groups" ("id") ON UPDATE NO ACTION ON DELETE CASCADE, CONSTRAINT "organization_control_creators_organization_id" FOREIGN KEY ("organization_id") REFERENCES "organizations" ("id") ON UPDATE NO ACTION ON DELETE CASCADE);
-- Create "organization_control_objective_creators" table
CREATE TABLE "organization_control_objective_creators" ("organization_id" character varying NOT NULL, "group_id" character varying NOT NULL, PRIMARY KEY ("organization_id", "group_id"), CONSTRAINT "organization_control_objective_creators_group_id" FOREIGN KEY ("group_id") REFERENCES "groups" ("id") ON UPDATE NO ACTION ON DELETE CASCADE, CONSTRAINT "organization_control_objective_creators_organization_id" FOREIGN KEY ("organization_id") REFERENCES "organizations" ("id") ON UPDATE NO ACTION ON DELETE CASCADE);
-- Create "organization_group_creators" table
CREATE TABLE "organization_group_creators" ("organization_id" character varying NOT NULL, "group_id" character varying NOT NULL, PRIMARY KEY ("organization_id", "group_id"), CONSTRAINT "organization_group_creators_group_id" FOREIGN KEY ("group_id") REFERENCES "groups" ("id") ON UPDATE NO ACTION ON DELETE CASCADE, CONSTRAINT "organization_group_creators_organization_id" FOREIGN KEY ("organization_id") REFERENCES "organizations" ("id") ON UPDATE NO ACTION ON DELETE CASCADE);
-- Create "organization_internal_policy_creators" table
CREATE TABLE "organization_internal_policy_creators" ("organization_id" character varying NOT NULL, "group_id" character varying NOT NULL, PRIMARY KEY ("organization_id", "group_id"), CONSTRAINT "organization_internal_policy_creators_group_id" FOREIGN KEY ("group_id") REFERENCES "groups" ("id") ON UPDATE NO ACTION ON DELETE CASCADE, CONSTRAINT "organization_internal_policy_creators_organization_id" FOREIGN KEY ("organization_id") REFERENCES "organizations" ("id") ON UPDATE NO ACTION ON DELETE CASCADE);
-- Create "organization_narrative_creators" table
CREATE TABLE "organization_narrative_creators" ("organization_id" character varying NOT NULL, "group_id" character varying NOT NULL, PRIMARY KEY ("organization_id", "group_id"), CONSTRAINT "organization_narrative_creators_group_id" FOREIGN KEY ("group_id") REFERENCES "groups" ("id") ON UPDATE NO ACTION ON DELETE CASCADE, CONSTRAINT "organization_narrative_creators_organization_id" FOREIGN KEY ("organization_id") REFERENCES "organizations" ("id") ON UPDATE NO ACTION ON DELETE CASCADE);
-- Create "organization_procedure_creators" table
CREATE TABLE "organization_procedure_creators" ("organization_id" character varying NOT NULL, "group_id" character varying NOT NULL, PRIMARY KEY ("organization_id", "group_id"), CONSTRAINT "organization_procedure_creators_group_id" FOREIGN KEY ("group_id") REFERENCES "groups" ("id") ON UPDATE NO ACTION ON DELETE CASCADE, CONSTRAINT "organization_procedure_creators_organization_id" FOREIGN KEY ("organization_id") REFERENCES "organizations" ("id") ON UPDATE NO ACTION ON DELETE CASCADE);
-- Create "organization_program_creators" table
CREATE TABLE "organization_program_creators" ("organization_id" character varying NOT NULL, "group_id" character varying NOT NULL, PRIMARY KEY ("organization_id", "group_id"), CONSTRAINT "organization_program_creators_group_id" FOREIGN KEY ("group_id") REFERENCES "groups" ("id") ON UPDATE NO ACTION ON DELETE CASCADE, CONSTRAINT "organization_program_creators_organization_id" FOREIGN KEY ("organization_id") REFERENCES "organizations" ("id") ON UPDATE NO ACTION ON DELETE CASCADE);
-- Create "organization_risk_creators" table
CREATE TABLE "organization_risk_creators" ("organization_id" character varying NOT NULL, "group_id" character varying NOT NULL, PRIMARY KEY ("organization_id", "group_id"), CONSTRAINT "organization_risk_creators_group_id" FOREIGN KEY ("group_id") REFERENCES "groups" ("id") ON UPDATE NO ACTION ON DELETE CASCADE, CONSTRAINT "organization_risk_creators_organization_id" FOREIGN KEY ("organization_id") REFERENCES "organizations" ("id") ON UPDATE NO ACTION ON DELETE CASCADE);
-- Create "organization_template_creators" table
CREATE TABLE "organization_template_creators" ("organization_id" character varying NOT NULL, "group_id" character varying NOT NULL, PRIMARY KEY ("organization_id", "group_id"), CONSTRAINT "organization_template_creators_group_id" FOREIGN KEY ("group_id") REFERENCES "groups" ("id") ON UPDATE NO ACTION ON DELETE CASCADE, CONSTRAINT "organization_template_creators_organization_id" FOREIGN KEY ("organization_id") REFERENCES "organizations" ("id") ON UPDATE NO ACTION ON DELETE CASCADE);
3 changes: 2 additions & 1 deletion db/migrations/atlas.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
h1:68ZN0QO+ffWGmXFZ6O2HU7meH9RHhnsvARfITM5S3Zo=
h1:mxakmpr1elO4QbwkSTxmWIb9kkiFuzbpuOeUbXiI+4w=
20240827061437_init.sql h1:9pQTZIsiDF3hW0HraVTzaU3M25iiy3MdxvhsZosxgvo=
20241014185633_object_upload.sql h1:0lzY0vj0gav3gMHGc8gm793zPeSQSMMHjt4c2V+7Eok=
20241108062010_compliance.sql h1:vmJyf1VhoKSRw9zRQKXsRtWJEEUYDbqZmpkyp89O/Tc=
Expand All @@ -10,3 +10,4 @@ h1:68ZN0QO+ffWGmXFZ6O2HU7meH9RHhnsvARfITM5S3Zo=
20241126203308_control_objectives.sql h1:e2DUn9RTWOR8fJl3PGdQ/YgzLfj585nNTeTiuvkAh+A=
20241126232456_narratives.sql h1:DhXbazPI/iSE0tDUGMoS/WHKXtQfO04v9b6qQPZ4aoQ=
20241201194355_controls.sql h1:lArKSEyGAIbk0Up6B7/RZTTZgVlB+rE09yJxQvK+30A=
20241203221235_creator_groups.sql h1:a6tKXzTkd+TlOgCfL/Iojb3zAU1DCQ5odiKw6nJvFRw=
Loading
Loading