Skip to content

Commit 6d74527

Browse files
Narayanbhat166hrithikesh026sai-harsha-vardhan
authored
refactor(router): remove id dependency from merchant connector account, dispute and mandate (#5330)
Co-authored-by: hrithikesh026 <[email protected]> Co-authored-by: sai-harsha-vardhan <[email protected]>
1 parent ef1418f commit 6d74527

File tree

9 files changed

+52
-7
lines changed

9 files changed

+52
-7
lines changed

crates/diesel_models/src/query/merchant_connector_account.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl MerchantConnectorAccount {
2525
) -> StorageResult<Self> {
2626
match generics::generic_update_by_id::<<Self as HasTable>::Table, _, _, _>(
2727
conn,
28-
self.id,
28+
self.merchant_connector_id.to_owned(),
2929
merchant_connector_account,
3030
)
3131
.await

crates/diesel_models/src/schema.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ diesel::table! {
336336
use diesel::sql_types::*;
337337
use crate::enums::diesel_exports::*;
338338

339-
dispute (id) {
339+
dispute (dispute_id) {
340340
id -> Int4,
341341
#[max_length = 64]
342342
dispute_id -> Varchar,
@@ -587,7 +587,7 @@ diesel::table! {
587587
use diesel::sql_types::*;
588588
use crate::enums::diesel_exports::*;
589589

590-
mandate (id) {
590+
mandate (mandate_id) {
591591
id -> Int4,
592592
#[max_length = 64]
593593
mandate_id -> Varchar,
@@ -677,7 +677,7 @@ diesel::table! {
677677
use diesel::sql_types::*;
678678
use crate::enums::diesel_exports::*;
679679

680-
merchant_connector_account (id) {
680+
merchant_connector_account (merchant_connector_id) {
681681
id -> Int4,
682682
#[max_length = 64]
683683
merchant_id -> Varchar,

crates/diesel_models/src/schema_v2.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ diesel::table! {
336336
use diesel::sql_types::*;
337337
use crate::enums::diesel_exports::*;
338338

339-
dispute (id) {
339+
dispute (dispute_id) {
340340
id -> Int4,
341341
#[max_length = 64]
342342
dispute_id -> Varchar,
@@ -587,7 +587,7 @@ diesel::table! {
587587
use diesel::sql_types::*;
588588
use crate::enums::diesel_exports::*;
589589

590-
mandate (id) {
590+
mandate (mandate_id) {
591591
id -> Int4,
592592
#[max_length = 64]
593593
mandate_id -> Varchar,
@@ -677,7 +677,7 @@ diesel::table! {
677677
use diesel::sql_types::*;
678678
use crate::enums::diesel_exports::*;
679679

680-
merchant_connector_account (id) {
680+
merchant_connector_account (merchant_connector_id) {
681681
id -> Int4,
682682
#[max_length = 64]
683683
merchant_id -> Varchar,
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ALTER TABLE dispute DROP CONSTRAINT dispute_pkey;
2+
3+
ALTER TABLE dispute ADD PRIMARY KEY (id);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-- Your SQL goes here
2+
-- The below query will lock the dispute table
3+
-- Running this query is not necessary on higher environments
4+
-- as the application will work fine without these queries being run
5+
-- This query is necessary for the application to not use id in update of dispute
6+
-- This query should be run only after the new version of application is deployed
7+
ALTER TABLE dispute DROP CONSTRAINT dispute_pkey;
8+
9+
-- Use the `dispute_id` column as primary key
10+
ALTER TABLE dispute
11+
ADD PRIMARY KEY (dispute_id);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ALTER TABLE mandate DROP CONSTRAINT mandate_pkey;
2+
3+
ALTER TABLE mandate ADD PRIMARY KEY (id);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-- Your SQL goes here
2+
-- The below query will lock the mandate table
3+
-- Running this query is not necessary on higher environments
4+
-- as the application will work fine without these queries being run
5+
-- This query is necessary for the application to not use id in update of mandate
6+
-- This query should be run only after the new version of application is deployed
7+
ALTER TABLE mandate DROP CONSTRAINT mandate_pkey;
8+
9+
-- Use the `mandate_id` column as primary key
10+
ALTER TABLE mandate
11+
ADD PRIMARY KEY (mandate_id);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- This file should undo anything in `up.sql`
2+
ALTER TABLE merchant_connector_account DROP CONSTRAINT merchant_connector_account_pkey;
3+
4+
ALTER TABLE merchant_connector_account
5+
ADD PRIMARY KEY (id);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-- Your SQL goes here
2+
-- The below query will lock the merchant connector account table
3+
-- Running this query is not necessary on higher environments
4+
-- as the application will work fine without these queries being run
5+
-- This query should be run only after the new version of application is deployed
6+
ALTER TABLE merchant_connector_account DROP CONSTRAINT merchant_connector_account_pkey;
7+
8+
-- Use the `merchant_connector_id` column as primary key
9+
-- This is not a unique column, but in an ideal scenario there should not be any duplicate keys as this is being generated by the application
10+
-- So this query should not fail for not null or duplicate values reasons
11+
ALTER TABLE merchant_connector_account
12+
ADD PRIMARY KEY (merchant_connector_id);

0 commit comments

Comments
 (0)