Skip to content

Commit

Permalink
fix(user_roles): migrations for backfilling user_roles entity_id (#6837)
Browse files Browse the repository at this point in the history
  • Loading branch information
Riddhiagrawal001 authored Dec 16, 2024
1 parent ed276ec commit 986de77
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
-- This file should undo anything in `up.sql`
SELECT 1;
UPDATE user_roles SET entity_type = NULL WHERE version = 'v1';
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
-- Your SQL goes here
-- Incomplete migration, also run migrations/2024-12-13-080558_entity-id-backfill-for-user-roles
UPDATE user_roles
SET
entity_type = CASE
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- This file should undo anything in `up.sql`
UPDATE user_roles SET entity_id = NULL WHERE version = 'v1';
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-- Your SQL goes here
UPDATE user_roles
SET
entity_id = CASE
WHEN role_id = 'org_admin' THEN org_id
ELSE merchant_id
END
WHERE
version = 'v1'
AND entity_id IS NULL;

0 comments on commit 986de77

Please sign in to comment.