-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(core): change primary keys in user, user_roles and roles tab…
…les (#5374)
- Loading branch information
1 parent
476aed5
commit b51c8e1
Showing
8 changed files
with
57 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
migrations/2024-07-19-095541_change_primary_key_for_users/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
12 changes: 12 additions & 0 deletions
12
migrations/2024-07-19-095541_change_primary_key_for_users/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
5 changes: 5 additions & 0 deletions
5
migrations/2024-07-19-100016_change_primary_key_for_user_roles/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
12 changes: 12 additions & 0 deletions
12
migrations/2024-07-19-100016_change_primary_key_for_user_roles/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
5 changes: 5 additions & 0 deletions
5
migrations/2024-07-19-100936_change_primary_key_for_roles/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
12 changes: 12 additions & 0 deletions
12
migrations/2024-07-19-100936_change_primary_key_for_roles/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |