mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 09:38:33 +08:00
refactor(schema): add a new column for storing large customer user agents in mandate table (#8616)
This commit is contained in:
@ -35,6 +35,8 @@ pub struct Mandate {
|
|||||||
pub original_payment_id: Option<common_utils::id_type::PaymentId>,
|
pub original_payment_id: Option<common_utils::id_type::PaymentId>,
|
||||||
pub merchant_connector_id: Option<common_utils::id_type::MerchantConnectorAccountId>,
|
pub merchant_connector_id: Option<common_utils::id_type::MerchantConnectorAccountId>,
|
||||||
pub updated_by: Option<String>,
|
pub updated_by: Option<String>,
|
||||||
|
// This is the extended version of customer user agent that can store string upto 2048 characters unlike customer user agent that can store 255 characters at max
|
||||||
|
pub customer_user_agent_extended: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
@ -73,6 +75,7 @@ pub struct MandateNew {
|
|||||||
pub original_payment_id: Option<common_utils::id_type::PaymentId>,
|
pub original_payment_id: Option<common_utils::id_type::PaymentId>,
|
||||||
pub merchant_connector_id: Option<common_utils::id_type::MerchantConnectorAccountId>,
|
pub merchant_connector_id: Option<common_utils::id_type::MerchantConnectorAccountId>,
|
||||||
pub updated_by: Option<String>,
|
pub updated_by: Option<String>,
|
||||||
|
pub customer_user_agent_extended: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MandateNew {
|
impl MandateNew {
|
||||||
@ -216,7 +219,7 @@ impl From<&MandateNew> for Mandate {
|
|||||||
mandate_type: mandate_new.mandate_type,
|
mandate_type: mandate_new.mandate_type,
|
||||||
customer_accepted_at: mandate_new.customer_accepted_at,
|
customer_accepted_at: mandate_new.customer_accepted_at,
|
||||||
customer_ip_address: mandate_new.customer_ip_address.clone(),
|
customer_ip_address: mandate_new.customer_ip_address.clone(),
|
||||||
customer_user_agent: mandate_new.customer_user_agent.clone(),
|
customer_user_agent: None,
|
||||||
network_transaction_id: mandate_new.network_transaction_id.clone(),
|
network_transaction_id: mandate_new.network_transaction_id.clone(),
|
||||||
previous_attempt_id: mandate_new.previous_attempt_id.clone(),
|
previous_attempt_id: mandate_new.previous_attempt_id.clone(),
|
||||||
created_at: mandate_new
|
created_at: mandate_new
|
||||||
@ -234,6 +237,11 @@ impl From<&MandateNew> for Mandate {
|
|||||||
original_payment_id: mandate_new.original_payment_id.clone(),
|
original_payment_id: mandate_new.original_payment_id.clone(),
|
||||||
merchant_connector_id: mandate_new.merchant_connector_id.clone(),
|
merchant_connector_id: mandate_new.merchant_connector_id.clone(),
|
||||||
updated_by: mandate_new.updated_by.clone(),
|
updated_by: mandate_new.updated_by.clone(),
|
||||||
|
// Using customer_user_agent as a fallback
|
||||||
|
customer_user_agent_extended: mandate_new
|
||||||
|
.customer_user_agent_extended
|
||||||
|
.clone()
|
||||||
|
.or_else(|| mandate_new.customer_user_agent.clone()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -723,6 +723,8 @@ diesel::table! {
|
|||||||
merchant_connector_id -> Nullable<Varchar>,
|
merchant_connector_id -> Nullable<Varchar>,
|
||||||
#[max_length = 64]
|
#[max_length = 64]
|
||||||
updated_by -> Nullable<Varchar>,
|
updated_by -> Nullable<Varchar>,
|
||||||
|
#[max_length = 2048]
|
||||||
|
customer_user_agent_extended -> Nullable<Varchar>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -736,6 +736,8 @@ diesel::table! {
|
|||||||
merchant_connector_id -> Nullable<Varchar>,
|
merchant_connector_id -> Nullable<Varchar>,
|
||||||
#[max_length = 64]
|
#[max_length = 64]
|
||||||
updated_by -> Nullable<Varchar>,
|
updated_by -> Nullable<Varchar>,
|
||||||
|
#[max_length = 2048]
|
||||||
|
customer_user_agent_extended -> Nullable<Varchar>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3439,7 +3439,7 @@ pub fn generate_mandate(
|
|||||||
.get_ip_address()
|
.get_ip_address()
|
||||||
.map(masking::Secret::new),
|
.map(masking::Secret::new),
|
||||||
)
|
)
|
||||||
.set_customer_user_agent(customer_acceptance.get_user_agent())
|
.set_customer_user_agent_extended(customer_acceptance.get_user_agent())
|
||||||
.set_customer_accepted_at(Some(customer_acceptance.get_accepted_at()))
|
.set_customer_accepted_at(Some(customer_acceptance.get_accepted_at()))
|
||||||
.set_metadata(payment_method_data_option.map(|payment_method_data| {
|
.set_metadata(payment_method_data_option.map(|payment_method_data| {
|
||||||
pii::SecretSerdeValue::new(
|
pii::SecretSerdeValue::new(
|
||||||
|
|||||||
@ -671,7 +671,7 @@ impl MandateInterface for MockDb {
|
|||||||
mandate_type: mandate_new.mandate_type,
|
mandate_type: mandate_new.mandate_type,
|
||||||
customer_accepted_at: mandate_new.customer_accepted_at,
|
customer_accepted_at: mandate_new.customer_accepted_at,
|
||||||
customer_ip_address: mandate_new.customer_ip_address,
|
customer_ip_address: mandate_new.customer_ip_address,
|
||||||
customer_user_agent: mandate_new.customer_user_agent,
|
customer_user_agent: None,
|
||||||
network_transaction_id: mandate_new.network_transaction_id,
|
network_transaction_id: mandate_new.network_transaction_id,
|
||||||
previous_attempt_id: mandate_new.previous_attempt_id,
|
previous_attempt_id: mandate_new.previous_attempt_id,
|
||||||
created_at: mandate_new
|
created_at: mandate_new
|
||||||
@ -688,6 +688,10 @@ impl MandateInterface for MockDb {
|
|||||||
connector_mandate_ids: mandate_new.connector_mandate_ids,
|
connector_mandate_ids: mandate_new.connector_mandate_ids,
|
||||||
merchant_connector_id: mandate_new.merchant_connector_id,
|
merchant_connector_id: mandate_new.merchant_connector_id,
|
||||||
updated_by: mandate_new.updated_by,
|
updated_by: mandate_new.updated_by,
|
||||||
|
// Using customer_user_agent as a fallback
|
||||||
|
customer_user_agent_extended: mandate_new
|
||||||
|
.customer_user_agent_extended
|
||||||
|
.or_else(|| mandate_new.customer_user_agent.clone()),
|
||||||
};
|
};
|
||||||
mandates.push(mandate.clone());
|
mandates.push(mandate.clone());
|
||||||
Ok(mandate)
|
Ok(mandate)
|
||||||
|
|||||||
@ -106,7 +106,11 @@ impl MandateResponseExt for MandateResponse {
|
|||||||
accepted_at: mandate.customer_accepted_at,
|
accepted_at: mandate.customer_accepted_at,
|
||||||
online: Some(api::payments::OnlineMandate {
|
online: Some(api::payments::OnlineMandate {
|
||||||
ip_address: mandate.customer_ip_address,
|
ip_address: mandate.customer_ip_address,
|
||||||
user_agent: mandate.customer_user_agent.unwrap_or_default(),
|
// Using customer_user_agent as a fallback
|
||||||
|
user_agent: mandate
|
||||||
|
.customer_user_agent_extended
|
||||||
|
.or(mandate.customer_user_agent)
|
||||||
|
.unwrap_or_default(),
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
card,
|
card,
|
||||||
|
|||||||
@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE mandate DROP COLUMN IF EXISTS customer_user_agent_extended;
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
ALTER TABLE mandate
|
||||||
|
ADD COLUMN
|
||||||
|
IF NOT EXISTS customer_user_agent_extended VARCHAR
|
||||||
|
(2048);
|
||||||
Reference in New Issue
Block a user