From 15191dc3f030e34e8dbe188e96059ffb0baf7dec Mon Sep 17 00:00:00 2001 From: spwoodcock Date: Wed, 10 Jan 2024 01:13:33 +0000 Subject: [PATCH] build: add migration for ProjectRole db enum type --- src/backend/migrations/003-project-roles.sql | 20 +++++++++++++++++++ .../migrations/revert/003-project-roles.sql | 11 ++++++++++ 2 files changed, 31 insertions(+) create mode 100644 src/backend/migrations/003-project-roles.sql create mode 100644 src/backend/migrations/revert/003-project-roles.sql diff --git a/src/backend/migrations/003-project-roles.sql b/src/backend/migrations/003-project-roles.sql new file mode 100644 index 0000000000..a2d1e5b99e --- /dev/null +++ b/src/backend/migrations/003-project-roles.sql @@ -0,0 +1,20 @@ +-- ## Migration to: +-- * Add public.projectrol enum. +-- * Update the user_roles table to use the enum + +-- Start a transaction +BEGIN; + +CREATE TYPE public.projectrole as ENUM ( + 'MAPPER', + 'VALIDATOR', + 'FIELD_MANAGER', + 'ASSOCIATE_PROJECT_MANAGER', + 'PROJECT_MANAGER', + 'ORGANIZATION_ADMIN' +); +ALTER TYPE public.projectrole OWNER TO fmtm; +ALTER TABLE public.user_roles ALTER COLUMN "role" TYPE public.projectrole; + +-- Commit the transaction +COMMIT; \ No newline at end of file diff --git a/src/backend/migrations/revert/003-project-roles.sql b/src/backend/migrations/revert/003-project-roles.sql new file mode 100644 index 0000000000..7c4853140a --- /dev/null +++ b/src/backend/migrations/revert/003-project-roles.sql @@ -0,0 +1,11 @@ +-- Start a transaction +BEGIN; + +-- Revert user_roles table changes +ALTER TABLE public.user_roles ALTER COLUMN "role" TYPE public.userrole; + +-- Drop the public.projectrole enum +DROP TYPE IF EXISTS public.projectrole; + +-- Commit the transaction +COMMIT;