-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(v1v2): refactor database queries for v1 and v2 #7244
base: main
Are you sure you want to change the base?
Conversation
-- It must be ensured that the deployed version of the application includes the `id` column in any of its queries. | ||
-- Re-create the id column as this was used as the primary key with a different type | ||
------------------------ Merchant Account ----------------------- | ||
ALTER TABLE merchant_account ADD COLUMN id SERIAL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make all these SERIAL to VARCHAR itself?
pub struct BlocklistFingerprint { | ||
#[serde(skip_serializing)] | ||
pub id: i32, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we cannot remove id from here right? This will not be backwards compatible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this will not be backwards compatible. Hence we need to go for a deployment with downtime. Instead of staggering.
@@ -49,7 +47,6 @@ impl From<ConfigUpdate> for ConfigUpdateInternal { | |||
impl From<ConfigNew> for Config { | |||
fn from(config_new: ConfigNew) -> Self { | |||
Self { | |||
id: 0i32, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we cannot remove this as well right? this will cause downtime
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes. We need to go with a downtime for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can add this in the patch for now, anyways we will need to have some downtime when deploying for v2, let's please add this in patch for now
@@ -52,6 +52,8 @@ pub struct MerchantAccount { | |||
pub pm_collect_link_config: Option<serde_json::Value>, | |||
pub version: common_enums::ApiVersion, | |||
pub is_platform_account: bool, | |||
pub id: Option<common_utils::id_type::MerchantId>, | |||
pub product_type: Option<common_enums::MerchantProductType>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can a merchant account be associated with only one product type? what if the merchant wants to use more than one product for the same merchant account?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is not allowed. Once a merchant is assigned a product_type
, it cannot be changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I mean is, can a merchant be associated with more than one product type at moment, both orchestrator and recovery service. Should this be a vector / hashset instead of just one element?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. One merchant can only belong to one product_type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the merchant wants to explore another product, they would need to create a new merchant_account.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a weird restriction to place though. I feel it's a valid use case to be able to use multiple products with the same merchant account.
Another question I have is about the API keys: is the merchant now expected to use different API keys in the same deployment of theirs, that uses our orchestration and vaulting products (or any two or more products for the matter)? Won't this become too much of a maintenance hassle for them?
@@ -5,7 +5,6 @@ diesel::table! { | |||
use crate::enums::diesel_exports::*; | |||
|
|||
address (address_id) { | |||
id -> Nullable<Int4>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
address table will not be present in v2, we can drop this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will take this up in a separate pr since this is outside the scope of this pr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes sure
@@ -764,6 +787,7 @@ impl super::behaviour::Conversion for MerchantAccount { | |||
async fn construct_new(self) -> CustomResult<Self::NewDstType, ValidationError> { | |||
let now = date_time::now(); | |||
Ok(diesel_models::merchant_account::MerchantAccountNew { | |||
id: None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this left None on purpose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, we will only allow v1 application to retrive v2 merchants, Not the other way around
ALTER TABLE payment_methods | ||
ADD COLUMN IF NOT EXISTS payment_method_id VARCHAR(64), | ||
ADD COLUMN IF NOT EXISTS accepted_currency "Currency" [ ], | ||
ADD COLUMN IF NOT EXISTS scheme VARCHAR(32), | ||
ADD COLUMN IF NOT EXISTS token VARCHAR(128), | ||
ADD COLUMN IF NOT EXISTS cardholder_name VARCHAR(255), | ||
ADD COLUMN IF NOT EXISTS issuer_name VARCHAR(64), | ||
ADD COLUMN IF NOT EXISTS issuer_country VARCHAR(64), | ||
ADD COLUMN IF NOT EXISTS is_stored BOOLEAN, | ||
ADD COLUMN IF NOT EXISTS direct_debit_token VARCHAR(128), | ||
ADD COLUMN IF NOT EXISTS swift_code VARCHAR(32), | ||
ADD COLUMN IF NOT EXISTS payment_method_issuer VARCHAR(128), | ||
ADD COLUMN IF NOT EXISTS metadata JSON, | ||
ADD COLUMN IF NOT EXISTS payment_method VARCHAR, | ||
ADD COLUMN IF NOT EXISTS payment_method_type VARCHAR(64), | ||
ADD COLUMN IF NOT EXISTS payment_method_issuer_code "PaymentMethodIssuerCode"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
payer_country
is not added back here while its being removed in up.sql?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few questions / nitpicks from my side. The nitpicks can be addressed separately, not a problem.
@@ -0,0 +1,28 @@ | |||
use serde; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Unnecessary import, can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am deriving serde::Deserialize and Serialize for enum ProductType
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I'm aware, you can directly use it in the derive()
line, you don't need the explicit use serde;
import.
#[derive( | ||
Default, | ||
Clone, | ||
Debug, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: This enum can also derive Copy
.
@@ -52,6 +52,8 @@ pub struct MerchantAccount { | |||
pub pm_collect_link_config: Option<serde_json::Value>, | |||
pub version: common_enums::ApiVersion, | |||
pub is_platform_account: bool, | |||
pub id: Option<common_utils::id_type::MerchantId>, | |||
pub product_type: Option<common_enums::MerchantProductType>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a weird restriction to place though. I feel it's a valid use case to be able to use multiple products with the same merchant account.
Another question I have is about the API keys: is the merchant now expected to use different API keys in the same deployment of theirs, that uses our orchestration and vaulting products (or any two or more products for the matter)? Won't this become too much of a maintenance hassle for them?
@@ -317,6 +324,7 @@ impl From<MerchantAccountUpdate> for MerchantAccountUpdateInternal { | |||
is_recon_enabled: None, | |||
recon_status: None, | |||
is_platform_account: None, | |||
product_type: None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Do we want to allow updating the product type once the merchant account has been created?
- If the answer for the above question is yes, then I don't see the
MerchantAccountUpdate
enum modified? So as it stands, the field would never be updated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Yes
product_type
will be populated only once after merchant account is created. Once it is populated, it cannot be modified. - That will be taken up later.
mkdir -p {{resultant_dir}} | ||
cp -r {{v1_migration_dir}}/* {{resultant_dir}}/ | ||
|
||
# Prefix v2 migrations with 9 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this being done so that v2 migrations always show up last in the combined list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
0c27611
87db6fe
Type of Change
Description
Other changes:
id
column from all possible v1 tables.id
column in merchant_account in v1.9
before copying to a common directory so that all v2 migration will run only after all v1 migrations are run).Additional Changes
Motivation and Context
How did you test it?
Tested connector sanity.

No test cases.
Checklist
cargo +nightly fmt --all
cargo clippy