Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
refactor(router): remove id dependency from merchant connector account, dispute and mandate (#5330)
Narayan Bhat6d74527f4428
diff --git a/crates/diesel_models/src/query/merchant_connector_account.rs b/crates/diesel_models/src/query/merchant_connector_account.rsindex bd24d12ec2..d275211ebd 100644--- a/crates/diesel_models/src/query/merchant_connector_account.rs+++ b/crates/diesel_models/src/query/merchant_connector_account.rs@@ -25,7 +25,7 @@ impl MerchantConnectorAccount {) -> StorageResult<Self> {match generics::generic_update_by_id::<<Self as HasTable>::Table, _, _, _>(conn,- self.id,+ self.merchant_connector_id.to_owned(),merchant_connector_account,).awaitdiff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rsindex a5185dc607..68689e8644 100644--- a/crates/diesel_models/src/schema.rs+++ b/crates/diesel_models/src/schema.rs@@ -336,7 +336,7 @@ diesel::table! {use diesel::sql_types::*;use crate::enums::diesel_exports::*;- dispute (id) {+ dispute (dispute_id) {id -> Int4,#[max_length = 64]dispute_id -> Varchar,@@ -587,7 +587,7 @@ diesel::table! {use diesel::sql_types::*;use crate::enums::diesel_exports::*;- mandate (id) {+ mandate (mandate_id) {id -> Int4,#[max_length = 64]mandate_id -> Varchar,@@ -677,7 +677,7 @@ diesel::table! {use diesel::sql_types::*;use crate::enums::diesel_exports::*;- merchant_connector_account (id) {+ merchant_connector_account (merchant_connector_id) {id -> Int4,#[max_length = 64]merchant_id -> Varchar,diff --git a/crates/diesel_models/src/schema_v2.rs b/crates/diesel_models/src/schema_v2.rsindex da8729cf83..e353cbd566 100644--- a/crates/diesel_models/src/schema_v2.rs+++ b/crates/diesel_models/src/schema_v2.rs@@ -336,7 +336,7 @@ diesel::table! {use diesel::sql_types::*;use crate::enums::diesel_exports::*;- dispute (id) {+ dispute (dispute_id) {id -> Int4,#[max_length = 64]dispute_id -> Varchar,@@ -587,7 +587,7 @@ diesel::table! {use diesel::sql_types::*;use crate::enums::diesel_exports::*;- mandate (id) {+ mandate (mandate_id) {id -> Int4,#[max_length = 64]mandate_id -> Varchar,@@ -677,7 +677,7 @@ diesel::table! {use diesel::sql_types::*;use crate::enums::diesel_exports::*;- merchant_connector_account (id) {+ merchant_connector_account (merchant_connector_id) {id -> Int4,#[max_length = 64]merchant_id -> Varchar,diff --git a/migrations/2024-07-15-120121_change_primary_key_for_dispute/down.sql b/migrations/2024-07-15-120121_change_primary_key_for_dispute/down.sqlnew file mode 100644index 0000000000..ff4e1664cb--- /dev/null+++ b/migrations/2024-07-15-120121_change_primary_key_for_dispute/down.sql@@ -0,0 +1,3 @@+ALTER TABLE dispute DROP CONSTRAINT dispute_pkey;++ALTER TABLE dispute ADD PRIMARY KEY (id);\ No newline at end of filediff --git a/migrations/2024-07-15-120121_change_primary_key_for_dispute/up.sql b/migrations/2024-07-15-120121_change_primary_key_for_dispute/up.sqlnew file mode 100644index 0000000000..794daa8850--- /dev/null+++ b/migrations/2024-07-15-120121_change_primary_key_for_dispute/up.sql@@ -0,0 +1,11 @@+-- Your SQL goes here+-- The below query will lock the dispute table+-- Running this query is not necessary on higher environments+-- as the application will work fine without these queries being run+-- This query is necessary for the application to not use id in update of dispute+-- This query should be run only after the new version of application is deployed+ALTER TABLE dispute DROP CONSTRAINT dispute_pkey;++-- Use the `dispute_id` column as primary key+ALTER TABLE dispute+ADD PRIMARY KEY (dispute_id);diff --git a/migrations/2024-07-15-143920_change_primary_key_for_mandate/down.sql b/migrations/2024-07-15-143920_change_primary_key_for_mandate/down.sqlnew file mode 100644index 0000000000..b04e648e07--- /dev/null+++ b/migrations/2024-07-15-143920_change_primary_key_for_mandate/down.sql@@ -0,0 +1,3 @@+ALTER TABLE mandate DROP CONSTRAINT mandate_pkey;++ALTER TABLE mandate ADD PRIMARY KEY (id);\ No newline at end of filediff --git a/migrations/2024-07-15-143920_change_primary_key_for_mandate/up.sql b/migrations/2024-07-15-143920_change_primary_key_for_mandate/up.sqlnew file mode 100644index 0000000000..13ff09a17e--- /dev/null+++ b/migrations/2024-07-15-143920_change_primary_key_for_mandate/up.sql@@ -0,0 +1,11 @@+-- Your SQL goes here+-- The below query will lock the mandate table+-- Running this query is not necessary on higher environments+-- as the application will work fine without these queries being run+-- This query is necessary for the application to not use id in update of mandate+-- This query should be run only after the new version of application is deployed+ALTER TABLE mandate DROP CONSTRAINT mandate_pkey;++-- Use the `mandate_id` column as primary key+ALTER TABLE mandate+ADD PRIMARY KEY (mandate_id);diff --git a/migrations/2024-07-15-170210_change_primary_key_for_merchant_connector_account/down.sql b/migrations/2024-07-15-170210_change_primary_key_for_merchant_connector_account/down.sqlnew file mode 100644index 0000000000..2107fd6370--- /dev/null+++ b/migrations/2024-07-15-170210_change_primary_key_for_merchant_connector_account/down.sql@@ -0,0 +1,5 @@+-- This file should undo anything in `up.sql`+ALTER TABLE merchant_connector_account DROP CONSTRAINT merchant_connector_account_pkey;++ALTER TABLE merchant_connector_account+ADD PRIMARY KEY (id);diff --git a/migrations/2024-07-15-170210_change_primary_key_for_merchant_connector_account/up.sql b/migrations/2024-07-15-170210_change_primary_key_for_merchant_connector_account/up.sqlnew file mode 100644index 0000000000..c12fc937bb--- /dev/null+++ b/migrations/2024-07-15-170210_change_primary_key_for_merchant_connector_account/up.sql@@ -0,0 +1,12 @@+-- Your SQL goes here+-- The below query will lock the merchant connector account 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 only after the new version of application is deployed+ALTER TABLE merchant_connector_account DROP CONSTRAINT merchant_connector_account_pkey;++-- Use the `merchant_connector_id` column as primary key+-- 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+-- So this query should not fail for not null or duplicate values reasons+ALTER TABLE merchant_connector_account+ADD PRIMARY KEY (merchant_connector_id);