Skip to content

Commit

Permalink
build: add migration for ProjectRole db enum type
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Jan 10, 2024
1 parent 293d25c commit 15191dc
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/backend/migrations/003-project-roles.sql
Original file line number Diff line number Diff line change
@@ -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;
11 changes: 11 additions & 0 deletions src/backend/migrations/revert/003-project-roles.sql
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 15191dc

Please sign in to comment.