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

@ -1168,7 +1168,7 @@ diesel::table! {
use diesel::sql_types::*;
use crate::enums::diesel_exports::*;
roles (id) {
roles (role_id) {
id -> Int4,
#[max_length = 64]
role_name -> Varchar,
@ -1251,7 +1251,7 @@ diesel::table! {
use diesel::sql_types::*;
use crate::enums::diesel_exports::*;
user_roles (id) {
user_roles (user_id, merchant_id) {
id -> Int4,
#[max_length = 64]
user_id -> Varchar,
@ -1275,7 +1275,7 @@ diesel::table! {
use diesel::sql_types::*;
use crate::enums::diesel_exports::*;
users (id) {
users (user_id) {
id -> Int4,
#[max_length = 64]
user_id -> Varchar,

View File

@ -1166,7 +1166,7 @@ diesel::table! {
use diesel::sql_types::*;
use crate::enums::diesel_exports::*;
roles (id) {
roles (role_id) {
id -> Int4,
#[max_length = 64]
role_name -> Varchar,
@ -1249,7 +1249,7 @@ diesel::table! {
use diesel::sql_types::*;
use crate::enums::diesel_exports::*;
user_roles (id) {
user_roles (user_id, merchant_id) {
id -> Int4,
#[max_length = 64]
user_id -> Varchar,
@ -1273,7 +1273,7 @@ diesel::table! {
use diesel::sql_types::*;
use crate::enums::diesel_exports::*;
users (id) {
users (user_id) {
id -> Int4,
#[max_length = 64]
user_id -> Varchar,

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