From 7076a2c4b203c10a5a615ab92536e79f2ff4b348 Mon Sep 17 00:00:00 2001 From: lorinjameson Date: Thu, 24 Oct 2024 08:51:16 -0400 Subject: [PATCH] Add metadata to tag definitions --- SQL Scripts/tables/tag_definitions.sql | 7 ++++++- SQL Scripts/utility/add_read_only_groups.sql | 11 +++++++++++ ...20241024125026_add_metadata_to_tag_definitions.sql | 3 +++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 supabase/migrations/20241024125026_add_metadata_to_tag_definitions.sql diff --git a/SQL Scripts/tables/tag_definitions.sql b/SQL Scripts/tables/tag_definitions.sql index a95bf4f..9950af8 100644 --- a/SQL Scripts/tables/tag_definitions.sql +++ b/SQL Scripts/tables/tag_definitions.sql @@ -14,7 +14,8 @@ CREATE TABLE tag_definitions name varchar NOT NULL, target_type tag_target_types NOT NULL, scope tag_scope_types NOT NULL, - scope_id uuid + scope_id uuid, + metadata json NOT NULL DEFAULT {} ); -- Changes 05/26/23 -- @@ -26,3 +27,7 @@ ALTER TABLE public.tag_definitions -- Changes 7/26/23 -- ALTER TABLE public.tag_definitions ADD COLUMN is_archived bool DEFAULT FALSE; + +-- Changes 10/24/24 +ALTER TABLE public.tag_definitions + ADD COLUMN metadata json NOT NULL DEFAULT '{}'; diff --git a/SQL Scripts/utility/add_read_only_groups.sql b/SQL Scripts/utility/add_read_only_groups.sql index 527f389..9cc00a5 100644 --- a/SQL Scripts/utility/add_read_only_groups.sql +++ b/SQL Scripts/utility/add_read_only_groups.sql @@ -8,6 +8,7 @@ DECLARE _is_default bool; _is_read_only bool; _layer_id uuid; + _project_id uuid; BEGIN -- Get the read-only default group FOR _role_id, _name, _description, _is_admin, _is_default, _is_read_only @@ -27,5 +28,15 @@ BEGIN END IF; END LOOP; END LOOP; + -- Set the Student role in project groups to read-only + FOR _project_id + IN SELECT p.id + FROM public.projects p + LOOP + -- For each project group set the Student role to read-only + UPDATE public.project_groups pg + SET is_read_only = TRUE + WHERE pg.is_default IS TRUE; + END LOOP; END $$ \ No newline at end of file diff --git a/supabase/migrations/20241024125026_add_metadata_to_tag_definitions.sql b/supabase/migrations/20241024125026_add_metadata_to_tag_definitions.sql new file mode 100644 index 0000000..92af429 --- /dev/null +++ b/supabase/migrations/20241024125026_add_metadata_to_tag_definitions.sql @@ -0,0 +1,3 @@ +alter table "public"."tag_definitions" add column "metadata" json not null default '{}'::json; + +