fix(user_roles): migrations for backfilling user_roles entity_id (#6837)

This commit is contained in:
Riddhiagrawal001
2024-12-16 16:17:59 +05:30
committed by GitHub
parent ed276ecc00
commit 986de77b48
4 changed files with 14 additions and 1 deletions

View File

@@ -1,2 +1,2 @@
-- This file should undo anything in `up.sql`
SELECT 1;
UPDATE user_roles SET entity_type = NULL WHERE version = 'v1';

View File

@@ -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

View File

@@ -0,0 +1,2 @@
-- This file should undo anything in `up.sql`
UPDATE user_roles SET entity_id = NULL WHERE version = 'v1';

View File

@@ -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;