refactor(core): change primary keys in user, user_roles and roles tables (#5374)

This commit is contained in:
Prajjwal Kumar
2024-07-19 18:26:40 +05:30
committed by GitHub
parent 476aed5036
commit b51c8e1d12
8 changed files with 57 additions and 6 deletions

View File

@ -0,0 +1,5 @@
-- This file should undo anything in `up.sql`
ALTER TABLE users DROP CONSTRAINT users_pkey;
ALTER TABLE users
ADD PRIMARY KEY (id);

View File

@ -0,0 +1,12 @@
-- Your SQL goes here
-- The below query will lock the users table
-- Running this query is not necessary on higher environments
-- as the application will work fine without these queries being run
-- This query should be run after the new version of application is deployed
ALTER TABLE users DROP CONSTRAINT users_pkey;
-- Use the `user_id` columns as primary key
-- These are already unique, not null column
-- So this query should not fail for not null or duplicate value reasons
ALTER TABLE users
ADD PRIMARY KEY (user_id);

View File

@ -0,0 +1,5 @@
-- This file should undo anything in `up.sql`
ALTER TABLE user_roles DROP CONSTRAINT user_roles_pkey;
ALTER TABLE user_roles
ADD PRIMARY KEY (id);

View File

@ -0,0 +1,12 @@
-- Your SQL goes here
-- The below query will lock the user_roles table
-- Running this query is not necessary on higher environments
-- as the application will work fine without these queries being run
-- This query should be run after the new version of application is deployed
ALTER TABLE user_roles DROP CONSTRAINT user_roles_pkey;
-- Use the `user_id, merchant_id` columns as primary key
-- These are already unique, not null columns
-- So this query should not fail for not null or duplicate value reasons
ALTER TABLE user_roles
ADD PRIMARY KEY (user_id, merchant_id);

View File

@ -0,0 +1,5 @@
-- This file should undo anything in `up.sql`
ALTER TABLE roles DROP CONSTRAINT roles_pkey;
ALTER TABLE roles
ADD PRIMARY KEY (id);

View File

@ -0,0 +1,12 @@
-- Your SQL goes here
-- The below query will lock the user_roles table
-- Running this query is not necessary on higher environments
-- as the application will work fine without these queries being run
-- This query should be run after the new version of application is deployed
ALTER TABLE roles DROP CONSTRAINT roles_pkey;
-- Use the `role_id` column as primary key
-- These are already unique, not null column
-- So this query should not fail for not null or duplicate value reasons
ALTER TABLE roles
ADD PRIMARY KEY (role_id);