mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 12:06:56 +08:00
refactor(v1v2): refactor database queries for v1 and v2 (#7244)
This commit is contained in:
@ -1,14 +1,15 @@
|
||||
mod accounts;
|
||||
mod payments;
|
||||
mod ui;
|
||||
use std::num::{ParseFloatError, TryFromIntError};
|
||||
|
||||
pub use accounts::MerchantProductType;
|
||||
pub use payments::ProductType;
|
||||
use serde::{Deserialize, Serialize};
|
||||
pub use ui::*;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
pub use super::connector_enums::RoutableConnectors;
|
||||
|
||||
#[doc(hidden)]
|
||||
pub mod diesel_exports {
|
||||
pub use super::{
|
||||
|
||||
28
crates/common_enums/src/enums/accounts.rs
Normal file
28
crates/common_enums/src/enums/accounts.rs
Normal file
@ -0,0 +1,28 @@
|
||||
use serde;
|
||||
use utoipa::ToSchema;
|
||||
#[derive(
|
||||
Default,
|
||||
Clone,
|
||||
Debug,
|
||||
Eq,
|
||||
PartialEq,
|
||||
serde::Deserialize,
|
||||
serde::Serialize,
|
||||
strum::Display,
|
||||
strum::EnumString,
|
||||
ToSchema,
|
||||
Hash,
|
||||
)]
|
||||
#[router_derive::diesel_enum(storage_type = "text")]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
pub enum MerchantProductType {
|
||||
Orchestration,
|
||||
#[default]
|
||||
Legacy,
|
||||
Vault,
|
||||
Recon,
|
||||
Recovery,
|
||||
CostObservability,
|
||||
DynamicRouting,
|
||||
}
|
||||
66
crates/diesel_models/drop_id.patch
Normal file
66
crates/diesel_models/drop_id.patch
Normal file
@ -0,0 +1,66 @@
|
||||
diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rs
|
||||
index b35e809a0..749a5dd47 100644
|
||||
--- a/crates/diesel_models/src/schema.rs
|
||||
+++ b/crates/diesel_models/src/schema.rs
|
||||
@@ -142,14 +142,13 @@ diesel::table! {
|
||||
}
|
||||
|
||||
diesel::table! {
|
||||
use diesel::sql_types::*;
|
||||
use crate::enums::diesel_exports::*;
|
||||
|
||||
- blocklist_fingerprint (id) {
|
||||
- id -> Int4,
|
||||
+ blocklist_fingerprint (merchant_id, fingerprint_id) {
|
||||
#[max_length = 64]
|
||||
merchant_id -> Varchar,
|
||||
#[max_length = 64]
|
||||
fingerprint_id -> Varchar,
|
||||
data_kind -> BlocklistDataKind,
|
||||
encrypted_fingerprint -> Text,
|
||||
@@ -158,14 +157,13 @@ diesel::table! {
|
||||
}
|
||||
|
||||
diesel::table! {
|
||||
use diesel::sql_types::*;
|
||||
use crate::enums::diesel_exports::*;
|
||||
|
||||
- blocklist_lookup (id) {
|
||||
- id -> Int4,
|
||||
+ blocklist_lookup (merchant_id, fingerprint) {
|
||||
#[max_length = 64]
|
||||
merchant_id -> Varchar,
|
||||
fingerprint -> Text,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,13 +298,12 @@ diesel::table! {
|
||||
|
||||
diesel::table! {
|
||||
use diesel::sql_types::*;
|
||||
use crate::enums::diesel_exports::*;
|
||||
|
||||
configs (key) {
|
||||
- id -> Int4,
|
||||
#[max_length = 255]
|
||||
key -> Varchar,
|
||||
config -> Text,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -615,14 +612,13 @@ diesel::table! {
|
||||
}
|
||||
|
||||
diesel::table! {
|
||||
use diesel::sql_types::*;
|
||||
use crate::enums::diesel_exports::*;
|
||||
|
||||
- locker_mock_up (id) {
|
||||
- id -> Int4,
|
||||
+ locker_mock_up (card_id) {
|
||||
#[max_length = 255]
|
||||
card_id -> Varchar,
|
||||
#[max_length = 255]
|
||||
external_id -> Varchar,
|
||||
#[max_length = 255]
|
||||
card_fingerprint -> Varchar,
|
||||
@ -1,108 +0,0 @@
|
||||
diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rs
|
||||
index 55f8e935b..469ad1d22 100644
|
||||
--- a/crates/diesel_models/src/schema.rs
|
||||
+++ b/crates/diesel_models/src/schema.rs
|
||||
@@ -5,7 +5,6 @@ diesel::table! {
|
||||
use crate::enums::diesel_exports::*;
|
||||
|
||||
address (address_id) {
|
||||
- id -> Nullable<Int4>,
|
||||
#[max_length = 64]
|
||||
address_id -> Varchar,
|
||||
#[max_length = 128]
|
||||
@@ -129,7 +128,6 @@ diesel::table! {
|
||||
use crate::enums::diesel_exports::*;
|
||||
|
||||
blocklist (merchant_id, fingerprint_id) {
|
||||
- id -> Int4,
|
||||
#[max_length = 64]
|
||||
merchant_id -> Varchar,
|
||||
#[max_length = 64]
|
||||
@@ -284,7 +282,6 @@ diesel::table! {
|
||||
use crate::enums::diesel_exports::*;
|
||||
|
||||
customers (customer_id, merchant_id) {
|
||||
- id -> Int4,
|
||||
#[max_length = 64]
|
||||
customer_id -> Varchar,
|
||||
#[max_length = 64]
|
||||
@@ -337,7 +334,6 @@ diesel::table! {
|
||||
use crate::enums::diesel_exports::*;
|
||||
|
||||
dispute (dispute_id) {
|
||||
- id -> Int4,
|
||||
#[max_length = 64]
|
||||
dispute_id -> Varchar,
|
||||
#[max_length = 255]
|
||||
@@ -588,7 +584,6 @@ diesel::table! {
|
||||
use crate::enums::diesel_exports::*;
|
||||
|
||||
mandate (mandate_id) {
|
||||
- id -> Int4,
|
||||
#[max_length = 64]
|
||||
mandate_id -> Varchar,
|
||||
#[max_length = 64]
|
||||
@@ -634,7 +629,6 @@ diesel::table! {
|
||||
use crate::enums::diesel_exports::*;
|
||||
|
||||
merchant_account (merchant_id) {
|
||||
- id -> Int4,
|
||||
#[max_length = 64]
|
||||
merchant_id -> Varchar,
|
||||
#[max_length = 255]
|
||||
@@ -678,7 +672,6 @@ diesel::table! {
|
||||
use crate::enums::diesel_exports::*;
|
||||
|
||||
merchant_connector_account (merchant_connector_id) {
|
||||
- id -> Int4,
|
||||
#[max_length = 64]
|
||||
merchant_id -> Varchar,
|
||||
#[max_length = 64]
|
||||
@@ -741,7 +734,6 @@ diesel::table! {
|
||||
use crate::enums::diesel_exports::*;
|
||||
|
||||
payment_attempt (attempt_id, merchant_id) {
|
||||
- id -> Nullable<Int4>,
|
||||
#[max_length = 64]
|
||||
payment_id -> Varchar,
|
||||
#[max_length = 64]
|
||||
@@ -832,7 +824,6 @@ diesel::table! {
|
||||
use crate::enums::diesel_exports::*;
|
||||
|
||||
payment_intent (payment_id, merchant_id) {
|
||||
- id -> Nullable<Int4>,
|
||||
#[max_length = 64]
|
||||
payment_id -> Varchar,
|
||||
#[max_length = 64]
|
||||
@@ -935,7 +926,6 @@ diesel::table! {
|
||||
use crate::enums::diesel_exports::*;
|
||||
|
||||
payment_methods (payment_method_id) {
|
||||
- id -> Int4,
|
||||
#[max_length = 64]
|
||||
customer_id -> Varchar,
|
||||
#[max_length = 64]
|
||||
@@ -1100,7 +1090,6 @@ diesel::table! {
|
||||
use crate::enums::diesel_exports::*;
|
||||
|
||||
refund (merchant_id, refund_id) {
|
||||
- id -> Int4,
|
||||
#[max_length = 64]
|
||||
internal_reference_id -> Varchar,
|
||||
#[max_length = 64]
|
||||
@@ -1169,7 +1158,6 @@ diesel::table! {
|
||||
use crate::enums::diesel_exports::*;
|
||||
|
||||
roles (role_id) {
|
||||
- id -> Int4,
|
||||
#[max_length = 64]
|
||||
role_name -> Varchar,
|
||||
#[max_length = 64]
|
||||
@@ -1276,7 +1263,6 @@ diesel::table! {
|
||||
use crate::enums::diesel_exports::*;
|
||||
|
||||
users (user_id) {
|
||||
- id -> Int4,
|
||||
#[max_length = 64]
|
||||
user_id -> Varchar,
|
||||
#[max_length = 255]
|
||||
@ -16,10 +16,8 @@ pub struct BlocklistFingerprintNew {
|
||||
#[derive(
|
||||
Clone, Debug, Eq, PartialEq, Queryable, Identifiable, Selectable, Deserialize, Serialize,
|
||||
)]
|
||||
#[diesel(table_name = blocklist_fingerprint, check_for_backend(diesel::pg::Pg))]
|
||||
#[diesel(table_name = blocklist_fingerprint, primary_key(merchant_id, fingerprint_id), check_for_backend(diesel::pg::Pg))]
|
||||
pub struct BlocklistFingerprint {
|
||||
#[serde(skip_serializing)]
|
||||
pub id: i32,
|
||||
pub merchant_id: common_utils::id_type::MerchantId,
|
||||
pub fingerprint_id: String,
|
||||
pub data_kind: common_enums::BlocklistDataKind,
|
||||
|
||||
@ -22,10 +22,8 @@ pub struct BlocklistLookupNew {
|
||||
Deserialize,
|
||||
Serialize,
|
||||
)]
|
||||
#[diesel(table_name = blocklist_lookup, check_for_backend(diesel::pg::Pg))]
|
||||
#[diesel(table_name = blocklist_lookup, primary_key(merchant_id, fingerprint), check_for_backend(diesel::pg::Pg))]
|
||||
pub struct BlocklistLookup {
|
||||
#[serde(skip)]
|
||||
pub id: i32,
|
||||
pub merchant_id: common_utils::id_type::MerchantId,
|
||||
pub fingerprint: String,
|
||||
}
|
||||
|
||||
@ -310,14 +310,6 @@ pub struct Profile {
|
||||
pub always_collect_shipping_details_from_wallet_connector: Option<bool>,
|
||||
pub tax_connector_id: Option<common_utils::id_type::MerchantConnectorAccountId>,
|
||||
pub is_tax_connector_enabled: Option<bool>,
|
||||
pub routing_algorithm_id: Option<common_utils::id_type::RoutingId>,
|
||||
pub order_fulfillment_time: Option<i64>,
|
||||
pub order_fulfillment_time_origin: Option<common_enums::OrderFulfillmentTimeOrigin>,
|
||||
pub frm_routing_algorithm_id: Option<String>,
|
||||
pub payout_routing_algorithm_id: Option<common_utils::id_type::RoutingId>,
|
||||
pub default_fallback_routing: Option<pii::SecretSerdeValue>,
|
||||
pub should_collect_cvv_during_payment: bool,
|
||||
pub id: common_utils::id_type::ProfileId,
|
||||
pub version: common_enums::ApiVersion,
|
||||
pub dynamic_routing_algorithm: Option<serde_json::Value>,
|
||||
pub is_network_tokenization_enabled: bool,
|
||||
@ -327,9 +319,17 @@ pub struct Profile {
|
||||
pub is_click_to_pay_enabled: bool,
|
||||
pub authentication_product_ids:
|
||||
Option<common_types::payments::AuthenticationConnectorAccountMap>,
|
||||
pub three_ds_decision_manager_config: Option<common_types::payments::DecisionManagerRecord>,
|
||||
pub card_testing_guard_config: Option<CardTestingGuardConfig>,
|
||||
pub card_testing_secret_key: Option<Encryption>,
|
||||
pub routing_algorithm_id: Option<common_utils::id_type::RoutingId>,
|
||||
pub order_fulfillment_time: Option<i64>,
|
||||
pub order_fulfillment_time_origin: Option<common_enums::OrderFulfillmentTimeOrigin>,
|
||||
pub frm_routing_algorithm_id: Option<String>,
|
||||
pub payout_routing_algorithm_id: Option<common_utils::id_type::RoutingId>,
|
||||
pub default_fallback_routing: Option<pii::SecretSerdeValue>,
|
||||
pub three_ds_decision_manager_config: Option<common_types::payments::DecisionManagerRecord>,
|
||||
pub should_collect_cvv_during_payment: bool,
|
||||
pub id: common_utils::id_type::ProfileId,
|
||||
}
|
||||
|
||||
impl Profile {
|
||||
|
||||
@ -13,10 +13,8 @@ pub struct ConfigNew {
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Debug, Identifiable, Queryable, Selectable, Deserialize, Serialize)]
|
||||
#[diesel(table_name = configs, check_for_backend(diesel::pg::Pg))]
|
||||
#[diesel(table_name = configs, primary_key(key), check_for_backend(diesel::pg::Pg))]
|
||||
pub struct Config {
|
||||
#[serde(skip)]
|
||||
pub id: i32,
|
||||
pub key: String,
|
||||
pub config: String,
|
||||
}
|
||||
@ -49,7 +47,6 @@ impl From<ConfigUpdate> for ConfigUpdateInternal {
|
||||
impl From<ConfigNew> for Config {
|
||||
fn from(config_new: ConfigNew) -> Self {
|
||||
Self {
|
||||
id: 0i32,
|
||||
key: config_new.key,
|
||||
config: config_new.config,
|
||||
}
|
||||
|
||||
@ -3,9 +3,8 @@ use diesel::{Identifiable, Insertable, Queryable, Selectable};
|
||||
use crate::schema::locker_mock_up;
|
||||
|
||||
#[derive(Clone, Debug, Eq, Identifiable, Queryable, Selectable, PartialEq)]
|
||||
#[diesel(table_name = locker_mock_up, check_for_backend(diesel::pg::Pg))]
|
||||
#[diesel(table_name = locker_mock_up, primary_key(card_id), check_for_backend(diesel::pg::Pg))]
|
||||
pub struct LockerMockUp {
|
||||
pub id: i32,
|
||||
pub card_id: String,
|
||||
pub external_id: String,
|
||||
pub card_fingerprint: String,
|
||||
|
||||
@ -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>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v1")]
|
||||
@ -85,12 +87,14 @@ pub struct MerchantAccountSetter {
|
||||
pub pm_collect_link_config: Option<serde_json::Value>,
|
||||
pub version: common_enums::ApiVersion,
|
||||
pub is_platform_account: bool,
|
||||
pub product_type: Option<common_enums::MerchantProductType>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v1")]
|
||||
impl From<MerchantAccountSetter> for MerchantAccount {
|
||||
fn from(item: MerchantAccountSetter) -> Self {
|
||||
Self {
|
||||
id: Some(item.merchant_id.clone()),
|
||||
merchant_id: item.merchant_id,
|
||||
return_url: item.return_url,
|
||||
enable_payment_response_hash: item.enable_payment_response_hash,
|
||||
@ -120,6 +124,7 @@ impl From<MerchantAccountSetter> for MerchantAccount {
|
||||
pm_collect_link_config: item.pm_collect_link_config,
|
||||
version: item.version,
|
||||
is_platform_account: item.is_platform_account,
|
||||
product_type: item.product_type,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -150,8 +155,9 @@ pub struct MerchantAccount {
|
||||
pub organization_id: common_utils::id_type::OrganizationId,
|
||||
pub recon_status: storage_enums::ReconStatus,
|
||||
pub version: common_enums::ApiVersion,
|
||||
pub id: common_utils::id_type::MerchantId,
|
||||
pub is_platform_account: bool,
|
||||
pub id: common_utils::id_type::MerchantId,
|
||||
pub product_type: Option<common_enums::MerchantProductType>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
@ -170,6 +176,7 @@ impl From<MerchantAccountSetter> for MerchantAccount {
|
||||
recon_status: item.recon_status,
|
||||
version: item.version,
|
||||
is_platform_account: item.is_platform_account,
|
||||
product_type: item.product_type,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -188,6 +195,7 @@ pub struct MerchantAccountSetter {
|
||||
pub recon_status: storage_enums::ReconStatus,
|
||||
pub version: common_enums::ApiVersion,
|
||||
pub is_platform_account: bool,
|
||||
pub product_type: Option<common_enums::MerchantProductType>,
|
||||
}
|
||||
|
||||
impl MerchantAccount {
|
||||
@ -235,6 +243,8 @@ pub struct MerchantAccountNew {
|
||||
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>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
@ -252,6 +262,7 @@ pub struct MerchantAccountNew {
|
||||
pub id: common_utils::id_type::MerchantId,
|
||||
pub version: common_enums::ApiVersion,
|
||||
pub is_platform_account: bool,
|
||||
pub product_type: Option<common_enums::MerchantProductType>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
@ -267,6 +278,7 @@ pub struct MerchantAccountUpdateInternal {
|
||||
pub organization_id: Option<common_utils::id_type::OrganizationId>,
|
||||
pub recon_status: Option<storage_enums::ReconStatus>,
|
||||
pub is_platform_account: Option<bool>,
|
||||
pub product_type: Option<common_enums::MerchantProductType>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
@ -282,6 +294,7 @@ impl MerchantAccountUpdateInternal {
|
||||
organization_id,
|
||||
recon_status,
|
||||
is_platform_account,
|
||||
product_type,
|
||||
} = self;
|
||||
|
||||
MerchantAccount {
|
||||
@ -297,6 +310,7 @@ impl MerchantAccountUpdateInternal {
|
||||
version: source.version,
|
||||
id: source.id,
|
||||
is_platform_account: is_platform_account.unwrap_or(source.is_platform_account),
|
||||
product_type: product_type.or(source.product_type),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -331,6 +345,7 @@ pub struct MerchantAccountUpdateInternal {
|
||||
pub payment_link_config: Option<serde_json::Value>,
|
||||
pub pm_collect_link_config: Option<serde_json::Value>,
|
||||
pub is_platform_account: Option<bool>,
|
||||
pub product_type: Option<common_enums::MerchantProductType>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v1")]
|
||||
@ -363,6 +378,7 @@ impl MerchantAccountUpdateInternal {
|
||||
payment_link_config,
|
||||
pm_collect_link_config,
|
||||
is_platform_account,
|
||||
product_type,
|
||||
} = self;
|
||||
|
||||
MerchantAccount {
|
||||
@ -399,6 +415,8 @@ impl MerchantAccountUpdateInternal {
|
||||
pm_collect_link_config: pm_collect_link_config.or(source.pm_collect_link_config),
|
||||
version: source.version,
|
||||
is_platform_account: is_platform_account.unwrap_or(source.is_platform_account),
|
||||
id: source.id,
|
||||
product_type: product_type.or(source.product_type),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,8 +98,8 @@ pub struct MerchantConnectorAccount {
|
||||
pub additional_merchant_data: Option<Encryption>,
|
||||
pub connector_wallets_details: Option<Encryption>,
|
||||
pub version: common_enums::ApiVersion,
|
||||
pub id: id_type::MerchantConnectorAccountId,
|
||||
pub feature_metadata: Option<MerchantConnectorAccountFeatureMetadata>,
|
||||
pub id: id_type::MerchantConnectorAccountId,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
|
||||
@ -82,6 +82,13 @@ pub struct PaymentAttempt {
|
||||
pub profile_id: id_type::ProfileId,
|
||||
pub organization_id: id_type::OrganizationId,
|
||||
pub card_network: Option<String>,
|
||||
pub shipping_cost: Option<MinorUnit>,
|
||||
pub order_tax_amount: Option<MinorUnit>,
|
||||
pub request_extended_authorization: Option<RequestExtendedAuthorizationBool>,
|
||||
pub extended_authorization_applied: Option<ExtendedAuthorizationAppliedBool>,
|
||||
pub capture_before: Option<PrimitiveDateTime>,
|
||||
pub card_discovery: Option<storage_enums::CardDiscovery>,
|
||||
pub charges: Option<common_types::payments::ConnectorChargeResponseData>,
|
||||
pub payment_method_type_v2: storage_enums::PaymentMethod,
|
||||
pub connector_payment_id: Option<ConnectorTransactionId>,
|
||||
pub payment_method_subtype: storage_enums::PaymentMethodType,
|
||||
@ -94,13 +101,6 @@ pub struct PaymentAttempt {
|
||||
pub connector_payment_data: Option<String>,
|
||||
pub connector_token_details: Option<ConnectorTokenDetails>,
|
||||
pub id: id_type::GlobalAttemptId,
|
||||
pub shipping_cost: Option<MinorUnit>,
|
||||
pub order_tax_amount: Option<MinorUnit>,
|
||||
pub request_extended_authorization: Option<RequestExtendedAuthorizationBool>,
|
||||
pub extended_authorization_applied: Option<ExtendedAuthorizationAppliedBool>,
|
||||
pub capture_before: Option<PrimitiveDateTime>,
|
||||
pub card_discovery: Option<storage_enums::CardDiscovery>,
|
||||
pub charges: Option<common_types::payments::ConnectorChargeResponseData>,
|
||||
pub feature_metadata: Option<PaymentAttemptFeatureMetadata>,
|
||||
}
|
||||
|
||||
@ -308,6 +308,8 @@ pub struct PaymentAttemptNew {
|
||||
pub card_network: Option<String>,
|
||||
pub shipping_cost: Option<MinorUnit>,
|
||||
pub order_tax_amount: Option<MinorUnit>,
|
||||
pub charges: Option<common_types::payments::ConnectorChargeResponseData>,
|
||||
pub feature_metadata: Option<PaymentAttemptFeatureMetadata>,
|
||||
pub payment_method_type_v2: storage_enums::PaymentMethod,
|
||||
pub payment_method_subtype: storage_enums::PaymentMethodType,
|
||||
pub id: id_type::GlobalAttemptId,
|
||||
@ -316,8 +318,6 @@ pub struct PaymentAttemptNew {
|
||||
pub request_extended_authorization: Option<RequestExtendedAuthorizationBool>,
|
||||
pub extended_authorization_applied: Option<ExtendedAuthorizationAppliedBool>,
|
||||
pub capture_before: Option<PrimitiveDateTime>,
|
||||
pub charges: Option<common_types::payments::ConnectorChargeResponseData>,
|
||||
pub feature_metadata: Option<PaymentAttemptFeatureMetadata>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v1")]
|
||||
|
||||
@ -58,6 +58,10 @@ pub struct PaymentIntent {
|
||||
pub organization_id: common_utils::id_type::OrganizationId,
|
||||
pub tax_details: Option<TaxDetails>,
|
||||
pub skip_external_tax_calculation: Option<bool>,
|
||||
pub request_extended_authorization: Option<RequestExtendedAuthorizationBool>,
|
||||
pub psd2_sca_exemption_type: Option<storage_enums::ScaExemptionType>,
|
||||
pub split_payments: Option<common_types::payments::SplitPaymentsRequest>,
|
||||
pub platform_merchant_id: Option<common_utils::id_type::MerchantId>,
|
||||
pub merchant_reference_id: Option<common_utils::id_type::PaymentReferenceId>,
|
||||
pub billing_address: Option<Encryption>,
|
||||
pub shipping_address: Option<Encryption>,
|
||||
@ -76,10 +80,6 @@ pub struct PaymentIntent {
|
||||
pub routing_algorithm_id: Option<common_utils::id_type::RoutingId>,
|
||||
pub payment_link_config: Option<PaymentLinkConfigRequestForPayments>,
|
||||
pub id: common_utils::id_type::GlobalPaymentId,
|
||||
pub request_extended_authorization: Option<RequestExtendedAuthorizationBool>,
|
||||
pub psd2_sca_exemption_type: Option<storage_enums::ScaExemptionType>,
|
||||
pub split_payments: Option<common_types::payments::SplitPaymentsRequest>,
|
||||
pub platform_merchant_id: Option<common_utils::id_type::MerchantId>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v1")]
|
||||
@ -380,8 +380,8 @@ pub struct PaymentIntentNew {
|
||||
pub skip_external_tax_calculation: Option<bool>,
|
||||
pub request_extended_authorization: Option<RequestExtendedAuthorizationBool>,
|
||||
pub psd2_sca_exemption_type: Option<storage_enums::ScaExemptionType>,
|
||||
pub platform_merchant_id: Option<common_utils::id_type::MerchantId>,
|
||||
pub split_payments: Option<common_types::payments::SplitPaymentsRequest>,
|
||||
pub platform_merchant_id: Option<common_utils::id_type::MerchantId>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
|
||||
@ -89,14 +89,14 @@ pub struct PaymentMethod {
|
||||
pub client_secret: Option<String>,
|
||||
pub payment_method_billing_address: Option<Encryption>,
|
||||
pub updated_by: Option<String>,
|
||||
pub locker_fingerprint_id: Option<String>,
|
||||
pub payment_method_type_v2: Option<storage_enums::PaymentMethod>,
|
||||
pub payment_method_subtype: Option<storage_enums::PaymentMethodType>,
|
||||
pub id: common_utils::id_type::GlobalPaymentMethodId,
|
||||
pub version: common_enums::ApiVersion,
|
||||
pub network_token_requestor_reference_id: Option<String>,
|
||||
pub network_token_locker_id: Option<String>,
|
||||
pub network_token_payment_method_data: Option<Encryption>,
|
||||
pub locker_fingerprint_id: Option<String>,
|
||||
pub payment_method_type_v2: Option<storage_enums::PaymentMethod>,
|
||||
pub payment_method_subtype: Option<storage_enums::PaymentMethodType>,
|
||||
pub id: common_utils::id_type::GlobalPaymentMethodId,
|
||||
}
|
||||
|
||||
impl PaymentMethod {
|
||||
@ -177,14 +177,14 @@ pub struct PaymentMethodNew {
|
||||
pub client_secret: Option<String>,
|
||||
pub payment_method_billing_address: Option<Encryption>,
|
||||
pub updated_by: Option<String>,
|
||||
pub locker_fingerprint_id: Option<String>,
|
||||
pub payment_method_type_v2: Option<storage_enums::PaymentMethod>,
|
||||
pub payment_method_subtype: Option<storage_enums::PaymentMethodType>,
|
||||
pub id: common_utils::id_type::GlobalPaymentMethodId,
|
||||
pub version: common_enums::ApiVersion,
|
||||
pub network_token_requestor_reference_id: Option<String>,
|
||||
pub network_token_locker_id: Option<String>,
|
||||
pub network_token_payment_method_data: Option<Encryption>,
|
||||
pub locker_fingerprint_id: Option<String>,
|
||||
pub payment_method_type_v2: Option<storage_enums::PaymentMethod>,
|
||||
pub payment_method_subtype: Option<storage_enums::PaymentMethodType>,
|
||||
pub id: common_utils::id_type::GlobalPaymentMethodId,
|
||||
}
|
||||
|
||||
impl PaymentMethodNew {
|
||||
|
||||
@ -145,8 +145,7 @@ diesel::table! {
|
||||
use diesel::sql_types::*;
|
||||
use crate::enums::diesel_exports::*;
|
||||
|
||||
blocklist_fingerprint (id) {
|
||||
id -> Int4,
|
||||
blocklist_fingerprint (merchant_id, fingerprint_id) {
|
||||
#[max_length = 64]
|
||||
merchant_id -> Varchar,
|
||||
#[max_length = 64]
|
||||
@ -161,8 +160,7 @@ diesel::table! {
|
||||
use diesel::sql_types::*;
|
||||
use crate::enums::diesel_exports::*;
|
||||
|
||||
blocklist_lookup (id) {
|
||||
id -> Int4,
|
||||
blocklist_lookup (merchant_id, fingerprint) {
|
||||
#[max_length = 64]
|
||||
merchant_id -> Varchar,
|
||||
fingerprint -> Text,
|
||||
@ -307,7 +305,6 @@ diesel::table! {
|
||||
use crate::enums::diesel_exports::*;
|
||||
|
||||
configs (key) {
|
||||
id -> Int4,
|
||||
#[max_length = 255]
|
||||
key -> Varchar,
|
||||
config -> Text,
|
||||
@ -622,8 +619,7 @@ diesel::table! {
|
||||
use diesel::sql_types::*;
|
||||
use crate::enums::diesel_exports::*;
|
||||
|
||||
locker_mock_up (id) {
|
||||
id -> Int4,
|
||||
locker_mock_up (card_id) {
|
||||
#[max_length = 255]
|
||||
card_id -> Varchar,
|
||||
#[max_length = 255]
|
||||
@ -742,6 +738,10 @@ diesel::table! {
|
||||
pm_collect_link_config -> Nullable<Jsonb>,
|
||||
version -> ApiVersion,
|
||||
is_platform_account -> Bool,
|
||||
#[max_length = 64]
|
||||
id -> Nullable<Varchar>,
|
||||
#[max_length = 64]
|
||||
product_type -> Nullable<Varchar>,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,6 @@ diesel::table! {
|
||||
use crate::enums::diesel_exports::*;
|
||||
|
||||
address (address_id) {
|
||||
id -> Nullable<Int4>,
|
||||
#[max_length = 64]
|
||||
address_id -> Varchar,
|
||||
#[max_length = 128]
|
||||
@ -132,7 +131,6 @@ diesel::table! {
|
||||
use crate::enums::diesel_exports::*;
|
||||
|
||||
blocklist (merchant_id, fingerprint_id) {
|
||||
id -> Int4,
|
||||
#[max_length = 64]
|
||||
merchant_id -> Varchar,
|
||||
#[max_length = 64]
|
||||
@ -207,6 +205,16 @@ diesel::table! {
|
||||
#[max_length = 64]
|
||||
tax_connector_id -> Nullable<Varchar>,
|
||||
is_tax_connector_enabled -> Nullable<Bool>,
|
||||
version -> ApiVersion,
|
||||
dynamic_routing_algorithm -> Nullable<Json>,
|
||||
is_network_tokenization_enabled -> Bool,
|
||||
is_auto_retries_enabled -> Nullable<Bool>,
|
||||
max_auto_retries_enabled -> Nullable<Int2>,
|
||||
always_request_extended_authorization -> Nullable<Bool>,
|
||||
is_click_to_pay_enabled -> Bool,
|
||||
authentication_product_ids -> Nullable<Jsonb>,
|
||||
card_testing_guard_config -> Nullable<Jsonb>,
|
||||
card_testing_secret_key -> Nullable<Bytea>,
|
||||
#[max_length = 64]
|
||||
routing_algorithm_id -> Nullable<Varchar>,
|
||||
order_fulfillment_time -> Nullable<Int8>,
|
||||
@ -216,20 +224,10 @@ diesel::table! {
|
||||
#[max_length = 64]
|
||||
payout_routing_algorithm_id -> Nullable<Varchar>,
|
||||
default_fallback_routing -> Nullable<Jsonb>,
|
||||
three_ds_decision_manager_config -> Nullable<Jsonb>,
|
||||
should_collect_cvv_during_payment -> Bool,
|
||||
#[max_length = 64]
|
||||
id -> Varchar,
|
||||
version -> ApiVersion,
|
||||
dynamic_routing_algorithm -> Nullable<Json>,
|
||||
is_network_tokenization_enabled -> Bool,
|
||||
is_auto_retries_enabled -> Nullable<Bool>,
|
||||
max_auto_retries_enabled -> Nullable<Int2>,
|
||||
always_request_extended_authorization -> Nullable<Bool>,
|
||||
is_click_to_pay_enabled -> Bool,
|
||||
authentication_product_ids -> Nullable<Jsonb>,
|
||||
three_ds_decision_manager_config -> Nullable<Jsonb>,
|
||||
card_testing_guard_config -> Nullable<Jsonb>,
|
||||
card_testing_secret_key -> Nullable<Bytea>,
|
||||
}
|
||||
}
|
||||
|
||||
@ -382,7 +380,6 @@ diesel::table! {
|
||||
use crate::enums::diesel_exports::*;
|
||||
|
||||
dispute (dispute_id) {
|
||||
id -> Int4,
|
||||
#[max_length = 64]
|
||||
dispute_id -> Varchar,
|
||||
#[max_length = 255]
|
||||
@ -671,7 +668,6 @@ diesel::table! {
|
||||
use crate::enums::diesel_exports::*;
|
||||
|
||||
mandate (mandate_id) {
|
||||
id -> Int4,
|
||||
#[max_length = 64]
|
||||
mandate_id -> Varchar,
|
||||
#[max_length = 64]
|
||||
@ -729,9 +725,11 @@ diesel::table! {
|
||||
organization_id -> Varchar,
|
||||
recon_status -> ReconStatus,
|
||||
version -> ApiVersion,
|
||||
is_platform_account -> Bool,
|
||||
#[max_length = 64]
|
||||
id -> Varchar,
|
||||
is_platform_account -> Bool,
|
||||
#[max_length = 64]
|
||||
product_type -> Nullable<Varchar>,
|
||||
}
|
||||
}
|
||||
|
||||
@ -763,9 +761,9 @@ diesel::table! {
|
||||
additional_merchant_data -> Nullable<Bytea>,
|
||||
connector_wallets_details -> Nullable<Bytea>,
|
||||
version -> ApiVersion,
|
||||
feature_metadata -> Nullable<Jsonb>,
|
||||
#[max_length = 64]
|
||||
id -> Varchar,
|
||||
feature_metadata -> Nullable<Jsonb>,
|
||||
}
|
||||
}
|
||||
|
||||
@ -862,6 +860,13 @@ diesel::table! {
|
||||
organization_id -> Varchar,
|
||||
#[max_length = 32]
|
||||
card_network -> Nullable<Varchar>,
|
||||
shipping_cost -> Nullable<Int8>,
|
||||
order_tax_amount -> Nullable<Int8>,
|
||||
request_extended_authorization -> Nullable<Bool>,
|
||||
extended_authorization_applied -> Nullable<Bool>,
|
||||
capture_before -> Nullable<Timestamp>,
|
||||
card_discovery -> Nullable<CardDiscovery>,
|
||||
charges -> Nullable<Jsonb>,
|
||||
payment_method_type_v2 -> Varchar,
|
||||
#[max_length = 128]
|
||||
connector_payment_id -> Nullable<Varchar>,
|
||||
@ -878,13 +883,6 @@ diesel::table! {
|
||||
connector_token_details -> Nullable<Jsonb>,
|
||||
#[max_length = 64]
|
||||
id -> Varchar,
|
||||
shipping_cost -> Nullable<Int8>,
|
||||
order_tax_amount -> Nullable<Int8>,
|
||||
request_extended_authorization -> Nullable<Bool>,
|
||||
extended_authorization_applied -> Nullable<Bool>,
|
||||
capture_before -> Nullable<Timestamp>,
|
||||
card_discovery -> Nullable<CardDiscovery>,
|
||||
charges -> Nullable<Jsonb>,
|
||||
feature_metadata -> Nullable<Jsonb>,
|
||||
}
|
||||
}
|
||||
@ -938,6 +936,11 @@ diesel::table! {
|
||||
organization_id -> Varchar,
|
||||
tax_details -> Nullable<Jsonb>,
|
||||
skip_external_tax_calculation -> Nullable<Bool>,
|
||||
request_extended_authorization -> Nullable<Bool>,
|
||||
psd2_sca_exemption_type -> Nullable<ScaExemptionType>,
|
||||
split_payments -> Nullable<Jsonb>,
|
||||
#[max_length = 64]
|
||||
platform_merchant_id -> Nullable<Varchar>,
|
||||
#[max_length = 64]
|
||||
merchant_reference_id -> Nullable<Varchar>,
|
||||
billing_address -> Nullable<Bytea>,
|
||||
@ -959,11 +962,6 @@ diesel::table! {
|
||||
payment_link_config -> Nullable<Jsonb>,
|
||||
#[max_length = 64]
|
||||
id -> Varchar,
|
||||
request_extended_authorization -> Nullable<Bool>,
|
||||
psd2_sca_exemption_type -> Nullable<ScaExemptionType>,
|
||||
split_payments -> Nullable<Jsonb>,
|
||||
#[max_length = 64]
|
||||
platform_merchant_id -> Nullable<Varchar>,
|
||||
}
|
||||
}
|
||||
|
||||
@ -1023,6 +1021,12 @@ diesel::table! {
|
||||
payment_method_billing_address -> Nullable<Bytea>,
|
||||
#[max_length = 64]
|
||||
updated_by -> Nullable<Varchar>,
|
||||
version -> ApiVersion,
|
||||
#[max_length = 128]
|
||||
network_token_requestor_reference_id -> Nullable<Varchar>,
|
||||
#[max_length = 64]
|
||||
network_token_locker_id -> Nullable<Varchar>,
|
||||
network_token_payment_method_data -> Nullable<Bytea>,
|
||||
#[max_length = 64]
|
||||
locker_fingerprint_id -> Nullable<Varchar>,
|
||||
#[max_length = 64]
|
||||
@ -1031,12 +1035,6 @@ diesel::table! {
|
||||
payment_method_subtype -> Nullable<Varchar>,
|
||||
#[max_length = 64]
|
||||
id -> Varchar,
|
||||
version -> ApiVersion,
|
||||
#[max_length = 128]
|
||||
network_token_requestor_reference_id -> Nullable<Varchar>,
|
||||
#[max_length = 64]
|
||||
network_token_locker_id -> Nullable<Varchar>,
|
||||
network_token_payment_method_data -> Nullable<Bytea>,
|
||||
}
|
||||
}
|
||||
|
||||
@ -1159,7 +1157,6 @@ diesel::table! {
|
||||
use crate::enums::diesel_exports::*;
|
||||
|
||||
refund (merchant_id, refund_id) {
|
||||
id -> Int4,
|
||||
#[max_length = 64]
|
||||
internal_reference_id -> Varchar,
|
||||
#[max_length = 64]
|
||||
@ -1266,7 +1263,6 @@ diesel::table! {
|
||||
use crate::enums::diesel_exports::*;
|
||||
|
||||
roles (role_id) {
|
||||
id -> Int4,
|
||||
#[max_length = 64]
|
||||
role_name -> Varchar,
|
||||
#[max_length = 64]
|
||||
@ -1441,7 +1437,6 @@ diesel::table! {
|
||||
use crate::enums::diesel_exports::*;
|
||||
|
||||
users (user_id) {
|
||||
id -> Int4,
|
||||
#[max_length = 64]
|
||||
user_id -> Varchar,
|
||||
#[max_length = 255]
|
||||
|
||||
@ -48,6 +48,7 @@ pub struct MerchantAccount {
|
||||
pub pm_collect_link_config: Option<serde_json::Value>,
|
||||
pub version: common_enums::ApiVersion,
|
||||
pub is_platform_account: bool,
|
||||
pub product_type: Option<common_enums::MerchantProductType>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v1")]
|
||||
@ -83,6 +84,7 @@ pub struct MerchantAccountSetter {
|
||||
pub pm_collect_link_config: Option<serde_json::Value>,
|
||||
pub version: common_enums::ApiVersion,
|
||||
pub is_platform_account: bool,
|
||||
pub product_type: Option<common_enums::MerchantProductType>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v1")]
|
||||
@ -118,6 +120,7 @@ impl From<MerchantAccountSetter> for MerchantAccount {
|
||||
pm_collect_link_config: item.pm_collect_link_config,
|
||||
version: item.version,
|
||||
is_platform_account: item.is_platform_account,
|
||||
product_type: item.product_type,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -137,6 +140,7 @@ pub struct MerchantAccountSetter {
|
||||
pub organization_id: common_utils::id_type::OrganizationId,
|
||||
pub recon_status: diesel_models::enums::ReconStatus,
|
||||
pub is_platform_account: bool,
|
||||
pub product_type: Option<common_enums::MerchantProductType>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
@ -154,6 +158,7 @@ impl From<MerchantAccountSetter> for MerchantAccount {
|
||||
organization_id,
|
||||
recon_status,
|
||||
is_platform_account,
|
||||
product_type,
|
||||
} = item;
|
||||
Self {
|
||||
id,
|
||||
@ -167,6 +172,7 @@ impl From<MerchantAccountSetter> for MerchantAccount {
|
||||
organization_id,
|
||||
recon_status,
|
||||
is_platform_account,
|
||||
product_type,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -185,6 +191,7 @@ pub struct MerchantAccount {
|
||||
pub organization_id: common_utils::id_type::OrganizationId,
|
||||
pub recon_status: diesel_models::enums::ReconStatus,
|
||||
pub is_platform_account: bool,
|
||||
pub product_type: Option<common_enums::MerchantProductType>,
|
||||
}
|
||||
|
||||
impl MerchantAccount {
|
||||
@ -316,6 +323,7 @@ impl From<MerchantAccountUpdate> for MerchantAccountUpdateInternal {
|
||||
is_recon_enabled: None,
|
||||
recon_status: None,
|
||||
is_platform_account: None,
|
||||
product_type: None,
|
||||
},
|
||||
MerchantAccountUpdate::StorageSchemeUpdate { storage_scheme } => Self {
|
||||
storage_scheme: Some(storage_scheme),
|
||||
@ -344,6 +352,7 @@ impl From<MerchantAccountUpdate> for MerchantAccountUpdateInternal {
|
||||
payment_link_config: None,
|
||||
pm_collect_link_config: None,
|
||||
is_platform_account: None,
|
||||
product_type: None,
|
||||
},
|
||||
MerchantAccountUpdate::ReconUpdate { recon_status } => Self {
|
||||
recon_status: Some(recon_status),
|
||||
@ -372,6 +381,7 @@ impl From<MerchantAccountUpdate> for MerchantAccountUpdateInternal {
|
||||
payment_link_config: None,
|
||||
pm_collect_link_config: None,
|
||||
is_platform_account: None,
|
||||
product_type: None,
|
||||
},
|
||||
MerchantAccountUpdate::UnsetDefaultProfile => Self {
|
||||
default_profile: Some(None),
|
||||
@ -400,6 +410,7 @@ impl From<MerchantAccountUpdate> for MerchantAccountUpdateInternal {
|
||||
payment_link_config: None,
|
||||
pm_collect_link_config: None,
|
||||
is_platform_account: None,
|
||||
product_type: None,
|
||||
},
|
||||
MerchantAccountUpdate::ModifiedAtUpdate => Self {
|
||||
modified_at: now,
|
||||
@ -428,6 +439,7 @@ impl From<MerchantAccountUpdate> for MerchantAccountUpdateInternal {
|
||||
payment_link_config: None,
|
||||
pm_collect_link_config: None,
|
||||
is_platform_account: None,
|
||||
product_type: None,
|
||||
},
|
||||
MerchantAccountUpdate::ToPlatformAccount => Self {
|
||||
modified_at: now,
|
||||
@ -456,6 +468,7 @@ impl From<MerchantAccountUpdate> for MerchantAccountUpdateInternal {
|
||||
payment_link_config: None,
|
||||
pm_collect_link_config: None,
|
||||
is_platform_account: Some(true),
|
||||
product_type: None,
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -482,6 +495,7 @@ impl From<MerchantAccountUpdate> for MerchantAccountUpdateInternal {
|
||||
organization_id: None,
|
||||
recon_status: None,
|
||||
is_platform_account: None,
|
||||
product_type: None,
|
||||
},
|
||||
MerchantAccountUpdate::StorageSchemeUpdate { storage_scheme } => Self {
|
||||
storage_scheme: Some(storage_scheme),
|
||||
@ -493,6 +507,7 @@ impl From<MerchantAccountUpdate> for MerchantAccountUpdateInternal {
|
||||
organization_id: None,
|
||||
recon_status: None,
|
||||
is_platform_account: None,
|
||||
product_type: None,
|
||||
},
|
||||
MerchantAccountUpdate::ReconUpdate { recon_status } => Self {
|
||||
recon_status: Some(recon_status),
|
||||
@ -504,6 +519,7 @@ impl From<MerchantAccountUpdate> for MerchantAccountUpdateInternal {
|
||||
metadata: None,
|
||||
organization_id: None,
|
||||
is_platform_account: None,
|
||||
product_type: None,
|
||||
},
|
||||
MerchantAccountUpdate::ModifiedAtUpdate => Self {
|
||||
modified_at: now,
|
||||
@ -515,6 +531,7 @@ impl From<MerchantAccountUpdate> for MerchantAccountUpdateInternal {
|
||||
organization_id: None,
|
||||
recon_status: None,
|
||||
is_platform_account: None,
|
||||
product_type: None,
|
||||
},
|
||||
MerchantAccountUpdate::ToPlatformAccount => Self {
|
||||
modified_at: now,
|
||||
@ -526,6 +543,7 @@ impl From<MerchantAccountUpdate> for MerchantAccountUpdateInternal {
|
||||
organization_id: None,
|
||||
recon_status: None,
|
||||
is_platform_account: Some(true),
|
||||
product_type: None,
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -552,6 +570,7 @@ impl super::behaviour::Conversion for MerchantAccount {
|
||||
recon_status: self.recon_status,
|
||||
version: crate::consts::API_VERSION,
|
||||
is_platform_account: self.is_platform_account,
|
||||
product_type: self.product_type,
|
||||
};
|
||||
|
||||
Ok(diesel_models::MerchantAccount::from(setter))
|
||||
@ -612,6 +631,7 @@ impl super::behaviour::Conversion for MerchantAccount {
|
||||
organization_id: item.organization_id,
|
||||
recon_status: item.recon_status,
|
||||
is_platform_account: item.is_platform_account,
|
||||
product_type: item.product_type,
|
||||
})
|
||||
}
|
||||
.await
|
||||
@ -634,6 +654,7 @@ impl super::behaviour::Conversion for MerchantAccount {
|
||||
recon_status: self.recon_status,
|
||||
version: crate::consts::API_VERSION,
|
||||
is_platform_account: self.is_platform_account,
|
||||
product_type: self.product_type,
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -674,6 +695,7 @@ impl super::behaviour::Conversion for MerchantAccount {
|
||||
pm_collect_link_config: self.pm_collect_link_config,
|
||||
version: self.version,
|
||||
is_platform_account: self.is_platform_account,
|
||||
product_type: self.product_type,
|
||||
};
|
||||
|
||||
Ok(diesel_models::MerchantAccount::from(setter))
|
||||
@ -752,6 +774,7 @@ impl super::behaviour::Conversion for MerchantAccount {
|
||||
pm_collect_link_config: item.pm_collect_link_config,
|
||||
version: item.version,
|
||||
is_platform_account: item.is_platform_account,
|
||||
product_type: item.product_type,
|
||||
})
|
||||
}
|
||||
.await
|
||||
@ -763,6 +786,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,
|
||||
merchant_id: self.merchant_id,
|
||||
merchant_name: self.merchant_name.map(Encryption::from),
|
||||
merchant_details: self.merchant_details.map(Encryption::from),
|
||||
@ -791,6 +815,7 @@ impl super::behaviour::Conversion for MerchantAccount {
|
||||
pm_collect_link_config: self.pm_collect_link_config,
|
||||
version: crate::consts::API_VERSION,
|
||||
is_platform_account: self.is_platform_account,
|
||||
product_type: self.product_type,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -403,6 +403,7 @@ impl MerchantAccountCreateBridge for api::MerchantAccountCreate {
|
||||
pm_collect_link_config,
|
||||
version: hyperswitch_domain_models::consts::API_VERSION,
|
||||
is_platform_account: false,
|
||||
product_type: None,
|
||||
},
|
||||
)
|
||||
}
|
||||
@ -671,6 +672,7 @@ impl MerchantAccountCreateBridge for api::MerchantAccountCreate {
|
||||
organization_id: organization.get_organization_id(),
|
||||
recon_status: diesel_models::enums::ReconStatus::NotRequested,
|
||||
is_platform_account: false,
|
||||
product_type: None,
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
use diesel_models::configs::ConfigUpdateInternal;
|
||||
use error_stack::{report, ResultExt};
|
||||
use error_stack::report;
|
||||
use router_env::{instrument, tracing};
|
||||
use storage_impl::redis::cache::{self, CacheKind, CONFIG_CACHE};
|
||||
|
||||
@ -191,7 +191,6 @@ impl ConfigInterface for MockDb {
|
||||
let mut configs = self.configs.lock().await;
|
||||
|
||||
let config_new = storage::Config {
|
||||
id: i32::try_from(configs.len()).change_context(errors::StorageError::MockDbError)?,
|
||||
key: config.key,
|
||||
config: config.config,
|
||||
};
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use error_stack::{report, ResultExt};
|
||||
use error_stack::report;
|
||||
use router_env::{instrument, tracing};
|
||||
|
||||
use super::{MockDb, Store};
|
||||
@ -88,8 +88,6 @@ impl LockerMockUpInterface for MockDb {
|
||||
}
|
||||
|
||||
let created_locker = storage::LockerMockUp {
|
||||
id: i32::try_from(locked_lockers.len())
|
||||
.change_context(errors::StorageError::MockDbError)?,
|
||||
card_id: new.card_id,
|
||||
external_id: new.external_id,
|
||||
card_fingerprint: new.card_fingerprint,
|
||||
|
||||
@ -5,4 +5,4 @@
|
||||
file = "crates/diesel_models/src/schema.rs"
|
||||
import_types = ["diesel::sql_types::*", "crate::enums::diesel_exports::*"]
|
||||
generate_missing_sql_type_definitions = false
|
||||
patch_file="crates/diesel_models/remove_id.patch"
|
||||
patch_file="crates/diesel_models/drop_id.patch"
|
||||
|
||||
16
justfile
16
justfile
@ -168,8 +168,20 @@ resultant_dir := source_directory() / 'final-migrations'
|
||||
# Copy v1 and v2 migrations to a single directory
|
||||
[private]
|
||||
copy_migrations:
|
||||
@mkdir -p {{ resultant_dir }}
|
||||
@cp -r {{ v1_migration_dir }}/. {{ v2_migration_dir }}/. {{ resultant_dir }}/
|
||||
#! /usr/bin/env bash
|
||||
mkdir -p {{resultant_dir}}
|
||||
cp -r {{v1_migration_dir}}/* {{resultant_dir}}/
|
||||
|
||||
# Prefix v2 migrations with 9
|
||||
sh -c '
|
||||
for dir in "{{v2_migration_dir}}"/*; do
|
||||
if [ -d "$dir" ]; then
|
||||
base_name=$(basename "$dir")
|
||||
new_name="9$base_name"
|
||||
cp -r "$dir" "{{resultant_dir}}/$new_name"
|
||||
fi
|
||||
done
|
||||
'
|
||||
echo "Created {{ resultant_dir }}"
|
||||
|
||||
# Delete the newly created directory
|
||||
|
||||
@ -0,0 +1,41 @@
|
||||
-- This file contains queries to re-create the `id` column as a `VARCHAR(64)` column for tables that had it removed.
|
||||
-- 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 VARCHAR(64);
|
||||
|
||||
------------------------ Merchant Connector Account -----------------------
|
||||
ALTER TABLE merchant_connector_account ADD COLUMN id VARCHAR(64);
|
||||
|
||||
------------------------ Customers -----------------------
|
||||
ALTER TABLE customers ADD COLUMN id VARCHAR(64);
|
||||
|
||||
------------------------ Payment Intent -----------------------
|
||||
ALTER TABLE payment_intent ADD COLUMN id VARCHAR(64);
|
||||
|
||||
------------------------ Payment Attempt -----------------------
|
||||
ALTER TABLE payment_attempt ADD COLUMN id VARCHAR(64);
|
||||
|
||||
------------------------ Payment Methods -----------------------
|
||||
ALTER TABLE payment_methods ADD COLUMN id VARCHAR(64);
|
||||
|
||||
------------------------ Address -----------------------
|
||||
ALTER TABLE address ADD COLUMN id VARCHAR(64);
|
||||
|
||||
------------------------ Dispute -----------------------
|
||||
ALTER TABLE dispute ADD COLUMN id VARCHAR(64);
|
||||
|
||||
------------------------ Mandate -----------------------
|
||||
ALTER TABLE mandate ADD COLUMN id VARCHAR(64);
|
||||
|
||||
------------------------ Refund -----------------------
|
||||
ALTER TABLE refund ADD COLUMN id VARCHAR(64);
|
||||
|
||||
------------------------ BlockList -----------------------
|
||||
ALTER TABLE blocklist ADD COLUMN id VARCHAR(64);
|
||||
|
||||
------------------------ Roles -----------------------
|
||||
ALTER TABLE roles ADD COLUMN id VARCHAR(64);
|
||||
|
||||
------------------------ Users -----------------------
|
||||
ALTER TABLE users ADD COLUMN id VARCHAR(64);
|
||||
@ -0,0 +1,47 @@
|
||||
-- This file contains queries to re-create the `id` column as a `VARCHAR` column instead of `SERIAL` column for tables that already have it.
|
||||
-- It must be ensured that the deployed version of the application does not include the `id` column in any of its queries.
|
||||
-- Drop the id column as this will be used later as the primary key with a different type
|
||||
------------------------ Merchant Account -----------------------
|
||||
ALTER TABLE merchant_account DROP COLUMN IF EXISTS id;
|
||||
|
||||
------------------------ Merchant Connector Account -----------------------
|
||||
ALTER TABLE merchant_connector_account DROP COLUMN IF EXISTS id;
|
||||
|
||||
|
||||
------------------------ Customers -----------------------
|
||||
ALTER TABLE customers DROP COLUMN IF EXISTS id;
|
||||
|
||||
|
||||
|
||||
------------------------ Payment Intent -----------------------
|
||||
ALTER TABLE payment_intent DROP COLUMN id;
|
||||
|
||||
|
||||
------------------------ Payment Attempt -----------------------
|
||||
ALTER TABLE payment_attempt DROP COLUMN id;
|
||||
|
||||
|
||||
------------------------ Payment Methods -----------------------
|
||||
ALTER TABLE payment_methods DROP COLUMN IF EXISTS id;
|
||||
|
||||
------------------------ Address -----------------------
|
||||
ALTER TABLE address DROP COLUMN IF EXISTS id;
|
||||
|
||||
------------------------ Dispute -----------------------
|
||||
ALTER TABLE dispute DROP COLUMN IF EXISTS id;
|
||||
|
||||
------------------------ Mandate -----------------------
|
||||
ALTER TABLE mandate DROP COLUMN IF EXISTS id;
|
||||
|
||||
------------------------ Refund -----------------------
|
||||
ALTER TABLE refund DROP COLUMN IF EXISTS id;
|
||||
|
||||
------------------------ BlockList -----------------------
|
||||
ALTER TABLE blocklist DROP COLUMN IF EXISTS id;
|
||||
|
||||
------------------------ Roles -----------------------
|
||||
ALTER TABLE roles DROP COLUMN IF EXISTS id;
|
||||
|
||||
------------------------ Users -----------------------
|
||||
ALTER TABLE users DROP COLUMN IF EXISTS id;
|
||||
|
||||
@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE merchant_account DROP id;
|
||||
@ -0,0 +1,3 @@
|
||||
-- Your SQL goes here
|
||||
ALTER TABLE merchant_account
|
||||
ADD COLUMN IF NOT EXISTS id VARCHAR(64);
|
||||
@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE merchant_account DROP product_type;
|
||||
@ -0,0 +1,3 @@
|
||||
-- Your SQL goes here
|
||||
ALTER TABLE merchant_account
|
||||
ADD COLUMN IF NOT EXISTS product_type VARCHAR(64);
|
||||
@ -1,42 +0,0 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE payment_methods
|
||||
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);
|
||||
|
||||
CREATE TYPE "PaymentMethodIssuerCode" AS ENUM (
|
||||
'jp_hdfc',
|
||||
'jp_icici',
|
||||
'jp_googlepay',
|
||||
'jp_applepay',
|
||||
'jp_phonepe',
|
||||
'jp_wechat',
|
||||
'jp_sofort',
|
||||
'jp_giropay',
|
||||
'jp_sepa',
|
||||
'jp_bacs'
|
||||
);
|
||||
|
||||
ALTER TABLE payment_methods ADD COLUMN IF NOT EXISTS payment_method_issuer_code "PaymentMethodIssuerCode";
|
||||
|
||||
ALTER TABLE payment_methods
|
||||
DROP COLUMN IF EXISTS locker_fingerprint_id,
|
||||
DROP COLUMN IF EXISTS payment_method_type_v2,
|
||||
DROP COLUMN IF EXISTS payment_method_subtype;
|
||||
|
||||
ALTER TABLE payment_methods ADD COLUMN IF NOT EXISTS payment_method_id VARCHAR(64);
|
||||
UPDATE payment_methods SET payment_method_id = id;
|
||||
ALTER TABLE payment_methods DROP CONSTRAINT IF EXISTS payment_methods_pkey;
|
||||
ALTER TABLE payment_methods ADD CONSTRAINT payment_methods_pkey PRIMARY KEY (payment_method_id);
|
||||
ALTER TABLE payment_methods DROP COLUMN IF EXISTS id;
|
||||
ALTER TABLE payment_methods ADD COLUMN IF NOT EXISTS id SERIAL;
|
||||
@ -1,31 +0,0 @@
|
||||
-- Your SQL goes here
|
||||
ALTER TABLE payment_methods
|
||||
DROP COLUMN IF EXISTS accepted_currency,
|
||||
DROP COLUMN IF EXISTS scheme,
|
||||
DROP COLUMN IF EXISTS token,
|
||||
DROP COLUMN IF EXISTS cardholder_name,
|
||||
DROP COLUMN IF EXISTS issuer_name,
|
||||
DROP COLUMN IF EXISTS issuer_country,
|
||||
DROP COLUMN IF EXISTS payer_country,
|
||||
DROP COLUMN IF EXISTS is_stored,
|
||||
DROP COLUMN IF EXISTS direct_debit_token,
|
||||
DROP COLUMN IF EXISTS swift_code,
|
||||
DROP COLUMN IF EXISTS payment_method_issuer,
|
||||
DROP COLUMN IF EXISTS payment_method_issuer_code,
|
||||
DROP COLUMN IF EXISTS metadata,
|
||||
DROP COLUMN IF EXISTS payment_method,
|
||||
DROP COLUMN IF EXISTS payment_method_type;
|
||||
|
||||
DROP TYPE IF EXISTS "PaymentMethodIssuerCode";
|
||||
|
||||
ALTER TABLE payment_methods
|
||||
ADD COLUMN IF NOT EXISTS locker_fingerprint_id VARCHAR(64),
|
||||
ADD COLUMN IF NOT EXISTS payment_method_type_v2 VARCHAR(64),
|
||||
ADD COLUMN IF NOT EXISTS payment_method_subtype VARCHAR(64);
|
||||
|
||||
ALTER TABLE payment_methods DROP COLUMN IF EXISTS id;
|
||||
ALTER TABLE payment_methods ADD COLUMN IF NOT EXISTS id VARCHAR(64);
|
||||
UPDATE payment_methods SET id = payment_method_id;
|
||||
ALTER TABLE payment_methods DROP CONSTRAINT IF EXISTS payment_methods_pkey;
|
||||
ALTER TABLE payment_methods ADD CONSTRAINT payment_methods_pkey PRIMARY KEY (id);
|
||||
ALTER TABLE payment_methods DROP COLUMN IF EXISTS payment_method_id;
|
||||
@ -11,7 +11,8 @@ ALTER TABLE business_profile DROP COLUMN routing_algorithm_id,
|
||||
DROP COLUMN frm_routing_algorithm_id,
|
||||
DROP COLUMN payout_routing_algorithm_id,
|
||||
DROP COLUMN default_fallback_routing,
|
||||
DROP COLUMN should_collect_cvv_during_payment;
|
||||
DROP COLUMN should_collect_cvv_during_payment,
|
||||
DROP COLUMN three_ds_decision_manager_config;
|
||||
|
||||
DROP TYPE "OrderFulfillmentTimeOrigin";
|
||||
|
||||
@ -46,4 +47,9 @@ ALTER TABLE payment_attempt DROP COLUMN payment_method_type_v2,
|
||||
DROP COLUMN connector_token_details;
|
||||
|
||||
ALTER TABLE merchant_connector_account
|
||||
ALTER COLUMN payment_methods_enabled TYPE JSON [ ];
|
||||
DROP COLUMN IF EXISTS feature_metadata;
|
||||
|
||||
ALTER TABLE payment_methods
|
||||
DROP COLUMN IF EXISTS locker_fingerprint_id,
|
||||
DROP COLUMN IF EXISTS payment_method_type_v2,
|
||||
DROP COLUMN IF EXISTS payment_method_subtype;
|
||||
@ -4,7 +4,7 @@ ALTER TABLE customers
|
||||
ADD COLUMN IF NOT EXISTS merchant_reference_id VARCHAR(64),
|
||||
ADD COLUMN IF NOT EXISTS default_billing_address BYTEA DEFAULT NULL,
|
||||
ADD COLUMN IF NOT EXISTS default_shipping_address BYTEA DEFAULT NULL,
|
||||
ADD COLUMN IF NOT EXISTS status "DeleteStatus" NOT NULL DEFAULT 'active';
|
||||
ADD COLUMN IF NOT EXISTS status "DeleteStatus";
|
||||
|
||||
CREATE TYPE "OrderFulfillmentTimeOrigin" AS ENUM ('create', 'confirm');
|
||||
|
||||
@ -15,13 +15,14 @@ ADD COLUMN routing_algorithm_id VARCHAR(64) DEFAULT NULL,
|
||||
ADD COLUMN frm_routing_algorithm_id VARCHAR(64) DEFAULT NULL,
|
||||
ADD COLUMN payout_routing_algorithm_id VARCHAR(64) DEFAULT NULL,
|
||||
ADD COLUMN default_fallback_routing JSONB DEFAULT NULL,
|
||||
ADD COLUMN three_ds_decision_manager_config jsonb,
|
||||
-- Intentionally not adding a default value here since we would have to
|
||||
-- check if any merchants have enabled this from configs table,
|
||||
-- before filling data for this column.
|
||||
-- If no merchants have enabled this, then we can use `false` as the default value
|
||||
-- when adding the column, later we can drop the default added for the column
|
||||
-- so that we ensure new records inserted always have a value for the column.
|
||||
ADD COLUMN should_collect_cvv_during_payment BOOLEAN NOT NULL;
|
||||
ADD COLUMN should_collect_cvv_during_payment BOOLEAN;
|
||||
|
||||
ALTER TABLE payment_intent
|
||||
ADD COLUMN merchant_reference_id VARCHAR(64),
|
||||
@ -56,4 +57,9 @@ ADD COLUMN payment_method_type_v2 VARCHAR,
|
||||
|
||||
-- Change the type of the column from JSON to JSONB
|
||||
ALTER TABLE merchant_connector_account
|
||||
ALTER COLUMN payment_methods_enabled TYPE JSONB [ ];
|
||||
ADD COLUMN IF NOT EXISTS feature_metadata JSONB;
|
||||
|
||||
ALTER TABLE payment_methods
|
||||
ADD COLUMN IF NOT EXISTS locker_fingerprint_id VARCHAR(64),
|
||||
ADD COLUMN IF NOT EXISTS payment_method_type_v2 VARCHAR(64),
|
||||
ADD COLUMN IF NOT EXISTS payment_method_subtype VARCHAR(64);
|
||||
@ -1,3 +1,39 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE organization ALTER COLUMN org_id SET NOT NULL;
|
||||
ALTER TABLE organization ADD PRIMARY KEY (org_id);
|
||||
------------------------ Organization -----------------------
|
||||
-- Re-add primary key constraint on `organization`
|
||||
ALTER TABLE organization
|
||||
ADD CONSTRAINT organization_pkey PRIMARY KEY (org_id),
|
||||
ALTER COLUMN org_id SET NOT NULL;
|
||||
|
||||
------------------------ Merchant Account -------------------
|
||||
ALTER TABLE merchant_account
|
||||
ADD PRIMARY KEY (merchant_id),
|
||||
ALTER COLUMN primary_business_details SET NOT NULL,
|
||||
ALTER COLUMN is_recon_enabled SET NOT NULL,
|
||||
ALTER COLUMN is_recon_enabled SET DEFAULT FALSE;
|
||||
|
||||
------------------------ Business Profile -------------------
|
||||
ALTER TABLE business_profile
|
||||
ADD PRIMARY KEY (profile_id);
|
||||
|
||||
---------------- Merchant Connector Account -----------------
|
||||
ALTER TABLE merchant_connector_account
|
||||
ADD PRIMARY KEY (merchant_connector_id);
|
||||
|
||||
------------------------ Customers --------------------------
|
||||
ALTER TABLE customers
|
||||
ADD PRIMARY KEY (merchant_id, customer_id);
|
||||
|
||||
---------------------- Payment Intent -----------------------
|
||||
ALTER TABLE payment_intent
|
||||
ADD PRIMARY KEY (payment_id, merchant_id),
|
||||
ALTER COLUMN active_attempt_id SET NOT NULL,
|
||||
ALTER COLUMN active_attempt_id SET DEFAULT 'xxx';
|
||||
|
||||
---------------------- Payment Attempt ----------------------
|
||||
ALTER TABLE payment_attempt
|
||||
ADD PRIMARY KEY (attempt_id, merchant_id),
|
||||
ALTER COLUMN amount SET NOT NULL;
|
||||
|
||||
---------------------- Payment Methods ----------------------
|
||||
ALTER TABLE payment_methods
|
||||
ADD PRIMARY KEY (payment_method_id);
|
||||
|
||||
@ -1,3 +1,39 @@
|
||||
-- Drop not null constraint on org_id in orgnaization table
|
||||
ALTER TABLE organization DROP CONSTRAINT organization_pkey;
|
||||
ALTER TABLE organization ALTER COLUMN org_id DROP NOT NULL;
|
||||
-- Drop not null constraint on org_id in organization table
|
||||
-- Drop not null constraint on org_id in organization table
|
||||
ALTER TABLE organization
|
||||
DROP CONSTRAINT organization_pkey,
|
||||
ALTER COLUMN org_id DROP NOT NULL;
|
||||
|
||||
-- Drop not null in merchant_account table for v1 columns that are dropped in v2
|
||||
ALTER TABLE merchant_account
|
||||
DROP CONSTRAINT merchant_account_pkey,
|
||||
ALTER COLUMN merchant_id DROP NOT NULL,
|
||||
ALTER COLUMN primary_business_details DROP NOT NULL,
|
||||
ALTER COLUMN is_recon_enabled DROP NOT NULL;
|
||||
|
||||
ALTER TABLE business_profile
|
||||
DROP CONSTRAINT business_profile_pkey,
|
||||
ALTER COLUMN profile_id DROP NOT NULL;
|
||||
|
||||
ALTER TABLE merchant_connector_account
|
||||
DROP CONSTRAINT merchant_connector_account_pkey,
|
||||
ALTER COLUMN merchant_connector_id DROP NOT NULL;
|
||||
|
||||
ALTER TABLE customers
|
||||
DROP CONSTRAINT customers_pkey,
|
||||
ALTER COLUMN customer_id DROP NOT NULL;
|
||||
|
||||
ALTER TABLE payment_intent
|
||||
DROP CONSTRAINT payment_intent_pkey,
|
||||
ALTER COLUMN payment_id DROP NOT NULL,
|
||||
ALTER COLUMN active_attempt_id DROP NOT NULL,
|
||||
ALTER COLUMN active_attempt_id DROP DEFAULT;
|
||||
|
||||
ALTER TABLE payment_attempt
|
||||
DROP CONSTRAINT payment_attempt_pkey,
|
||||
ALTER COLUMN attempt_id DROP NOT NULL,
|
||||
ALTER COLUMN amount DROP NOT NULL;
|
||||
|
||||
ALTER TABLE payment_methods
|
||||
DROP CONSTRAINT payment_methods_pkey,
|
||||
ALTER COLUMN payment_method_id DROP NOT NULL;
|
||||
|
||||
@ -1,26 +1,21 @@
|
||||
-- This file contains queries to create the `id` column as a `SERIAL` column instead of `VARCHAR` column for tables that already have it.
|
||||
-- This is to revert the `id` columns to the previous state.
|
||||
ALTER TABLE merchant_account DROP id;
|
||||
|
||||
ALTER TABLE merchant_account
|
||||
ADD COLUMN IF NOT EXISTS id SERIAL;
|
||||
|
||||
ALTER TABLE merchant_connector_account DROP COLUMN IF EXISTS id;
|
||||
|
||||
ALTER TABLE merchant_connector_account
|
||||
ADD COLUMN IF NOT EXISTS id SERIAL;
|
||||
|
||||
ALTER TABLE business_profile DROP COLUMN IF EXISTS id;
|
||||
|
||||
ALTER TABLE customers DROP COLUMN IF EXISTS id;
|
||||
|
||||
ALTER TABLE customers
|
||||
ADD COLUMN IF NOT EXISTS id SERIAL;
|
||||
|
||||
|
||||
ALTER TABLE payment_intent DROP COLUMN IF EXISTS id;
|
||||
|
||||
ALTER TABLE payment_intent
|
||||
ADD id SERIAL;
|
||||
|
||||
|
||||
ALTER TABLE payment_attempt DROP COLUMN IF EXISTS id;
|
||||
|
||||
ALTER TABLE payment_attempt
|
||||
ADD id SERIAL;
|
||||
|
||||
------------------------ Payment Methods -----------------------
|
||||
ALTER TABLE payment_methods DROP COLUMN IF EXISTS id;
|
||||
|
||||
|
||||
@ -1,35 +1,39 @@
|
||||
-- This file contains queries to re-create the `id` column as a `VARCHAR` column instead of `SERIAL` column for tables that already have it.
|
||||
-- It must be ensured that the deployed version of the application does not include the `id` column in any of its queries.
|
||||
-- Drop the id column as this will be used later as the primary key with a different type
|
||||
------------------------ Merchant Account -----------------------
|
||||
ALTER TABLE merchant_account DROP COLUMN IF EXISTS id;
|
||||
|
||||
-- Adding a new column called `id` which will be the new primary key for v2
|
||||
-- Note that even though this will be the new primary key, the v1 application would still fill in null values
|
||||
ALTER TABLE merchant_account
|
||||
ADD COLUMN id VARCHAR(64);
|
||||
|
||||
------------------------ Merchant Connector Account -----------------------
|
||||
-- This migration is to modify the id column in merchant_connector_account table to be a VARCHAR(64) and to set the id column as primary key
|
||||
ALTER TABLE merchant_connector_account DROP COLUMN IF EXISTS id;
|
||||
|
||||
ALTER TABLE merchant_connector_account
|
||||
ADD COLUMN IF NOT EXISTS id VARCHAR(64);
|
||||
|
||||
------------------------ Business Profile -----------------------
|
||||
-- This migration is to modify the id column in business_profile table to be a VARCHAR(64) and to set the id column as primary key
|
||||
ALTER TABLE business_profile
|
||||
ADD COLUMN id VARCHAR(64);
|
||||
|
||||
------------------------ Customers -----------------------
|
||||
ALTER TABLE customers DROP COLUMN IF EXISTS id;
|
||||
|
||||
|
||||
ALTER TABLE customers
|
||||
ADD COLUMN IF NOT EXISTS id VARCHAR(64);
|
||||
|
||||
------------------------ Payment Intent -----------------------
|
||||
ALTER TABLE payment_intent DROP COLUMN id;
|
||||
|
||||
|
||||
ALTER TABLE payment_intent
|
||||
ADD COLUMN IF NOT EXISTS id VARCHAR(64);
|
||||
|
||||
------------------------ Payment Attempt -----------------------
|
||||
ALTER TABLE payment_attempt DROP COLUMN id;
|
||||
|
||||
|
||||
ALTER TABLE payment_attempt
|
||||
ADD COLUMN IF NOT EXISTS id VARCHAR(64);
|
||||
|
||||
------------------------ Payment Methods -----------------------
|
||||
|
||||
|
||||
ALTER TABLE payment_methods
|
||||
ADD COLUMN IF NOT EXISTS id VARCHAR(64);
|
||||
|
||||
|
||||
@ -5,105 +5,63 @@ SET org_id = id
|
||||
WHERE org_id IS NULL;
|
||||
|
||||
ALTER TABLE ORGANIZATION DROP CONSTRAINT organization_pkey_id;
|
||||
|
||||
ALTER TABLE ORGANIZATION DROP CONSTRAINT organization_organization_name_key;
|
||||
|
||||
-- back fill
|
||||
-- Backfill
|
||||
UPDATE ORGANIZATION
|
||||
SET org_name = organization_name
|
||||
WHERE org_name IS NULL
|
||||
AND organization_name IS NOT NULL;
|
||||
WHERE org_name IS NULL AND organization_name IS NOT NULL;
|
||||
|
||||
------------------------ Merchant Account -----------------------
|
||||
-- The new primary key for v2 merchant account will be `id`
|
||||
ALTER TABLE merchant_account DROP CONSTRAINT merchant_account_pkey;
|
||||
ALTER TABLE merchant_account ALTER COLUMN id DROP NOT NULL;
|
||||
|
||||
-- In order to run this query, the merchant_id column should be unique and not null
|
||||
-- We need to backfill the id, a simple strategy will be to copy the values of id to merchant_id
|
||||
-- Query to update the merchant_id column with values of id
|
||||
-- Backfill the id, a simple strategy will be to copy the values of id to merchant_id
|
||||
UPDATE merchant_account
|
||||
SET merchant_id = id
|
||||
WHERE merchant_id IS NULL;
|
||||
|
||||
-- Note: This command might not run successfully for the existing table
|
||||
-- This is because there will be some rows ( which are created via v2 application ) which will have id as empty
|
||||
-- A backfill might be required to run this query
|
||||
-- However if this is being run on a fresh database, this should succeed
|
||||
ALTER TABLE merchant_account
|
||||
ADD PRIMARY KEY (merchant_id);
|
||||
|
||||
------------------------ Business Profile -----------------------
|
||||
ALTER TABLE business_profile DROP CONSTRAINT business_profile_pkey;
|
||||
ALTER TABLE business_profile ALTER COLUMN id DROP NOT NULL;
|
||||
|
||||
UPDATE business_profile
|
||||
SET profile_id = id
|
||||
WHERE profile_id IS NULL;
|
||||
|
||||
ALTER TABLE business_profile DROP COLUMN id;
|
||||
|
||||
ALTER TABLE business_profile
|
||||
ADD PRIMARY KEY (profile_id);
|
||||
|
||||
------------------------ Merchant Connector Account -----------------------
|
||||
ALTER TABLE merchant_connector_account DROP CONSTRAINT merchant_connector_account_pkey;
|
||||
ALTER TABLE merchant_connector_account ALTER COLUMN id DROP NOT NULL;
|
||||
|
||||
UPDATE merchant_connector_account
|
||||
SET merchant_connector_id = id
|
||||
WHERE merchant_connector_id IS NULL;
|
||||
|
||||
ALTER TABLE merchant_connector_account
|
||||
ADD PRIMARY KEY (merchant_connector_id);
|
||||
|
||||
ALTER TABLE merchant_connector_account
|
||||
ALTER COLUMN profile_id DROP NOT NULL;
|
||||
|
||||
DROP INDEX IF EXISTS merchant_connector_account_profile_id_index;
|
||||
|
||||
------------------------ Customers -----------------------
|
||||
-- Run this query only when V1 is deprecated
|
||||
ALTER TABLE customers DROP CONSTRAINT customers_pkey;
|
||||
ALTER TABLE customers ALTER COLUMN id DROP NOT NULL;
|
||||
|
||||
-- Back filling before making it primary key
|
||||
-- Backfill before making it primary key
|
||||
UPDATE customers
|
||||
SET customer_id = id
|
||||
WHERE customer_id IS NULL;
|
||||
|
||||
ALTER TABLE customers
|
||||
ADD PRIMARY KEY (merchant_id, customer_id);
|
||||
|
||||
------------------------ Payment Intent -----------------------
|
||||
ALTER TABLE payment_intent DROP CONSTRAINT payment_intent_pkey;
|
||||
ALTER TABLE payment_intent ALTER COLUMN id DROP NOT NULL;
|
||||
|
||||
UPDATE payment_intent
|
||||
SET payment_id = id
|
||||
WHERE payment_id IS NULL;
|
||||
|
||||
ALTER TABLE payment_intent
|
||||
ADD PRIMARY KEY (payment_id, merchant_id);
|
||||
|
||||
ALTER TABLE payment_intent
|
||||
ALTER COLUMN currency DROP NOT NULL,
|
||||
ALTER COLUMN client_secret DROP NOT NULL,
|
||||
ALTER COLUMN profile_id DROP NOT NULL;
|
||||
|
||||
ALTER TABLE payment_intent
|
||||
ALTER COLUMN active_attempt_id
|
||||
SET NOT NULL;
|
||||
|
||||
ALTER TABLE payment_intent
|
||||
ALTER COLUMN session_expiry DROP NOT NULL;
|
||||
|
||||
ALTER TABLE payment_intent
|
||||
ALTER COLUMN active_attempt_id
|
||||
SET DEFAULT 'xxx';
|
||||
|
||||
------------------------ Payment Attempt -----------------------
|
||||
ALTER TABLE payment_attempt DROP CONSTRAINT payment_attempt_pkey;
|
||||
ALTER TABLE payment_attempt ALTER COLUMN id DROP NOT NULL;
|
||||
|
||||
UPDATE payment_attempt
|
||||
SET attempt_id = id
|
||||
WHERE attempt_id IS NULL;
|
||||
|
||||
ALTER TABLE payment_attempt
|
||||
ALTER COLUMN net_amount DROP NOT NULL;
|
||||
|
||||
ALTER TABLE payment_attempt
|
||||
ADD PRIMARY KEY (attempt_id, merchant_id);
|
||||
------------------------ Payment Methods -----------------------
|
||||
ALTER TABLE payment_methods DROP CONSTRAINT payment_methods_pkey;
|
||||
ALTER TABLE payment_methods ALTER COLUMN id DROP NOT NULL;
|
||||
|
||||
@ -1,14 +1,15 @@
|
||||
-- This file contains queries to update the primary key constraints suitable to the v2 application.
|
||||
-- This also has queries to update other constraints and indexes on tables where applicable.
|
||||
|
||||
------------------------ Organization -----------------------
|
||||
-- Update null id and organization_name fields
|
||||
UPDATE ORGANIZATION
|
||||
SET id = org_id
|
||||
WHERE id IS NULL;
|
||||
|
||||
UPDATE ORGANIZATION
|
||||
SET organization_name = org_name
|
||||
WHERE organization_name IS NULL
|
||||
AND org_name IS NOT NULL;
|
||||
WHERE organization_name IS NULL AND org_name IS NOT NULL;
|
||||
|
||||
-- Alter queries for organization table
|
||||
ALTER TABLE ORGANIZATION
|
||||
@ -18,119 +19,60 @@ ALTER TABLE ORGANIZATION
|
||||
ADD CONSTRAINT organization_organization_name_key UNIQUE (organization_name);
|
||||
|
||||
------------------------ Merchant Account -----------------------
|
||||
-- The new primary key for v2 merchant account will be `id`
|
||||
ALTER TABLE merchant_account DROP CONSTRAINT merchant_account_pkey;
|
||||
|
||||
-- In order to make id as primary key, it should be unique and not null
|
||||
-- We need to backfill the id, a simple strategy will be to copy the values of merchant_id to id
|
||||
-- Query to update the id column with values of merchant_id
|
||||
-- Note: This query will lock the table, so it should be run when there is no traffic
|
||||
-- Backfill id column with merchant_id values
|
||||
UPDATE merchant_account
|
||||
SET id = merchant_id
|
||||
WHERE id IS NULL;
|
||||
|
||||
-- Note: This command might not run successfully for the existing table
|
||||
-- This is because there will be some rows ( which are created via v1 application ) which will have id as empty
|
||||
-- A backfill might be required to run this query
|
||||
-- However if this is being run on a fresh database, this should succeed
|
||||
-- Add primary key constraint
|
||||
ALTER TABLE merchant_account
|
||||
ADD PRIMARY KEY (id);
|
||||
|
||||
------------------------ Business Profile -----------------------
|
||||
-- This migration is to modify the id column in business_profile table to be a VARCHAR(64) and to set the id column as primary key
|
||||
ALTER TABLE business_profile
|
||||
ADD COLUMN id VARCHAR(64);
|
||||
|
||||
-- Backfill the id column with the profile_id to prevent null values
|
||||
-- Backfill id column with profile_id values
|
||||
UPDATE business_profile
|
||||
SET id = profile_id
|
||||
WHERE id IS NULL;
|
||||
|
||||
ALTER TABLE business_profile DROP CONSTRAINT business_profile_pkey;
|
||||
|
||||
-- Add primary key constraint
|
||||
ALTER TABLE business_profile
|
||||
ADD PRIMARY KEY (id);
|
||||
|
||||
------------------------ Merchant Connector Account -----------------------
|
||||
-- Backfill the id column with the merchant_connector_id to prevent null values
|
||||
-- Backfill id column with merchant_connector_id values
|
||||
UPDATE merchant_connector_account
|
||||
SET id = merchant_connector_id
|
||||
WHERE id IS NULL;
|
||||
|
||||
ALTER TABLE merchant_connector_account DROP CONSTRAINT merchant_connector_account_pkey;
|
||||
|
||||
-- Add primary key constraint
|
||||
ALTER TABLE merchant_connector_account
|
||||
ADD PRIMARY KEY (id);
|
||||
|
||||
-- This migration is to make profile_id mandatory in mca table
|
||||
ALTER TABLE merchant_connector_account
|
||||
ALTER COLUMN profile_id
|
||||
SET NOT NULL;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS merchant_connector_account_profile_id_index ON merchant_connector_account (profile_id);
|
||||
-- Create index on profile_id
|
||||
CREATE INDEX IF NOT EXISTS merchant_connector_account_profile_id_index
|
||||
ON merchant_connector_account (profile_id);
|
||||
|
||||
------------------------ Customers -----------------------
|
||||
-- Run this query only when V1 is deprecated
|
||||
ALTER TABLE customers DROP CONSTRAINT IF EXISTS customers_pkey;
|
||||
|
||||
-- Back filling before making it primary key
|
||||
-- This will fail when making `id` as primary key, if the `customer_id` column has duplicate values.
|
||||
-- Another option is to use a randomly generated ID instead.
|
||||
-- Backfill id column with customer_id values
|
||||
UPDATE customers
|
||||
SET id = customer_id
|
||||
WHERE id IS NULL;
|
||||
|
||||
-- Add primary key constraint
|
||||
ALTER TABLE customers
|
||||
ADD PRIMARY KEY (id);
|
||||
|
||||
------------------------ Payment Intent -----------------------
|
||||
ALTER TABLE payment_intent DROP CONSTRAINT payment_intent_pkey;
|
||||
|
||||
-- Add primary key constraint
|
||||
ALTER TABLE payment_intent
|
||||
ADD PRIMARY KEY (id);
|
||||
|
||||
------------------------ Payment Attempt -----------------------
|
||||
ALTER TABLE payment_attempt DROP CONSTRAINT payment_attempt_pkey;
|
||||
|
||||
-- Add primary key constraint
|
||||
ALTER TABLE payment_attempt
|
||||
ADD PRIMARY KEY (id);
|
||||
|
||||
-- This migration is to make fields mandatory in payment_intent table
|
||||
ALTER TABLE payment_intent
|
||||
ALTER COLUMN profile_id
|
||||
SET NOT NULL,
|
||||
ALTER COLUMN currency
|
||||
SET NOT NULL,
|
||||
ALTER COLUMN client_secret
|
||||
SET NOT NULL,
|
||||
ALTER COLUMN session_expiry
|
||||
SET NOT NULL,
|
||||
ALTER COLUMN active_attempt_id DROP NOT NULL;
|
||||
|
||||
------------------------ Payment Attempt -----------------------
|
||||
ALTER TABLE payment_attempt DROP CONSTRAINT payment_attempt_pkey;
|
||||
|
||||
ALTER TABLE payment_attempt
|
||||
------------------------ Payment Methods -----------------------
|
||||
-- Add primary key constraint
|
||||
ALTER TABLE payment_methods
|
||||
ADD PRIMARY KEY (id);
|
||||
|
||||
-- This migration is to make fields mandatory in payment_attempt table
|
||||
ALTER TABLE payment_attempt
|
||||
ALTER COLUMN net_amount
|
||||
SET NOT NULL,
|
||||
ALTER COLUMN authentication_type
|
||||
SET NOT NULL,
|
||||
ALTER COLUMN payment_method_type_v2
|
||||
SET NOT NULL,
|
||||
ALTER COLUMN payment_method_subtype
|
||||
SET NOT NULL;
|
||||
|
||||
ALTER TABLE payment_intent
|
||||
ALTER COLUMN session_expiry
|
||||
SET NOT NULL;
|
||||
|
||||
-- This migration is to make fields optional in payment_intent table
|
||||
ALTER TABLE payment_intent
|
||||
ALTER COLUMN active_attempt_id DROP NOT NULL;
|
||||
|
||||
ALTER TABLE payment_intent
|
||||
ALTER COLUMN active_attempt_id DROP DEFAULT;
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE customers
|
||||
ALTER COLUMN status DROP NOT NULL,
|
||||
ALTER COLUMN status DROP DEFAULT;
|
||||
|
||||
---------------------business_profile---------------------
|
||||
ALTER TABLE business_profile ALTER COLUMN should_collect_cvv_during_payment DROP NOT NULL;
|
||||
|
||||
|
||||
ALTER TABLE merchant_connector_account
|
||||
ALTER COLUMN profile_id DROP NOT NULL;
|
||||
|
||||
ALTER TABLE payment_intent
|
||||
ALTER COLUMN profile_id DROP NOT NULL,
|
||||
ALTER COLUMN currency DROP NOT NULL,
|
||||
ALTER COLUMN client_secret DROP NOT NULL,
|
||||
ALTER COLUMN session_expiry DROP NOT NULL;
|
||||
|
||||
ALTER TABLE payment_attempt
|
||||
ALTER COLUMN net_amount DROP NOT NULL;
|
||||
|
||||
-- This migration is to make fields mandatory in payment_attempt table
|
||||
ALTER TABLE payment_attempt
|
||||
ALTER COLUMN net_amount DROP NOT NULL,
|
||||
ALTER COLUMN authentication_type DROP NOT NULL,
|
||||
ALTER COLUMN payment_method_type_v2 DROP NOT NULL,
|
||||
ALTER COLUMN payment_method_subtype DROP NOT NULL;
|
||||
@ -0,0 +1,26 @@
|
||||
-- Your SQL goes here
|
||||
|
||||
ALTER TABLE customers
|
||||
ALTER COLUMN status SET NOT NULL,
|
||||
ALTER COLUMN status SET DEFAULT 'active';
|
||||
|
||||
---------------------business_profile---------------------
|
||||
ALTER TABLE business_profile ALTER COLUMN should_collect_cvv_during_payment SET NOT NULL;
|
||||
|
||||
-- This migration is to make profile_id mandatory in mca table
|
||||
ALTER TABLE merchant_connector_account
|
||||
ALTER COLUMN profile_id SET NOT NULL;
|
||||
|
||||
-- This migration is to make fields mandatory in payment_intent table
|
||||
ALTER TABLE payment_intent
|
||||
ALTER COLUMN profile_id SET NOT NULL,
|
||||
ALTER COLUMN currency SET NOT NULL,
|
||||
ALTER COLUMN client_secret SET NOT NULL,
|
||||
ALTER COLUMN session_expiry SET NOT NULL;
|
||||
|
||||
-- This migration is to make fields mandatory in payment_attempt table
|
||||
ALTER TABLE payment_attempt
|
||||
ALTER COLUMN net_amount SET NOT NULL,
|
||||
ALTER COLUMN authentication_type SET NOT NULL,
|
||||
ALTER COLUMN payment_method_type_v2 SET NOT NULL,
|
||||
ALTER COLUMN payment_method_subtype SET NOT NULL;
|
||||
@ -1,9 +1,9 @@
|
||||
ALTER TABLE ORGANIZATION
|
||||
ADD COLUMN org_id VARCHAR(32),
|
||||
ADD COLUMN org_id VARCHAR(32),
|
||||
ADD COLUMN org_name TEXT;
|
||||
|
||||
ALTER TABLE merchant_account
|
||||
ADD COLUMN merchant_id VARCHAR(64),
|
||||
ADD COLUMN merchant_id VARCHAR(64),
|
||||
ADD COLUMN return_url VARCHAR(255),
|
||||
ADD COLUMN enable_payment_response_hash BOOLEAN DEFAULT FALSE,
|
||||
ADD COLUMN payment_response_hash_key VARCHAR(255),
|
||||
@ -15,45 +15,42 @@ ADD COLUMN merchant_id VARCHAR(64),
|
||||
ADD COLUMN default_profile VARCHAR(64),
|
||||
ADD COLUMN payment_link_config JSONB NULL,
|
||||
ADD COLUMN pm_collect_link_config JSONB NULL,
|
||||
ADD COLUMN is_recon_enabled BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
ADD COLUMN webhook_details JSONB NULL,
|
||||
ADD COLUMN is_recon_enabled BOOLEAN,
|
||||
ADD COLUMN webhook_details JSON NULL,
|
||||
ADD COLUMN routing_algorithm JSON,
|
||||
ADD COLUMN frm_routing_algorithm JSONB,
|
||||
ADD COLUMN payout_routing_algorithm JSONB;
|
||||
|
||||
-- The default value is for temporary purpose only
|
||||
ALTER TABLE merchant_account
|
||||
ADD COLUMN primary_business_details JSON NOT NULL DEFAULT '[{"country": "US", "business": "default"}]';
|
||||
|
||||
ALTER TABLE merchant_account
|
||||
ALTER COLUMN primary_business_details DROP DEFAULT;
|
||||
ADD COLUMN primary_business_details JSON;
|
||||
|
||||
ALTER TABLE business_profile
|
||||
ADD COLUMN profile_id VARCHAR(64),
|
||||
ADD COLUMN profile_id VARCHAR(64),
|
||||
ADD COLUMN routing_algorithm JSON DEFAULT NULL,
|
||||
ADD COLUMN intent_fulfillment_time BIGINT DEFAULT NULL,
|
||||
ADD COLUMN frm_routing_algorithm JSONB DEFAULT NULL,
|
||||
ADD COLUMN payout_routing_algorithm JSONB DEFAULT NULL;
|
||||
|
||||
ALTER TABLE merchant_connector_account
|
||||
ADD COLUMN IF NOT EXISTS business_country "CountryAlpha2",
|
||||
ADD COLUMN IF NOT EXISTS business_country "CountryAlpha2",
|
||||
ADD COLUMN IF NOT EXISTS business_label VARCHAR(255),
|
||||
ADD COLUMN IF NOT EXISTS business_sub_label VARCHAR(64),
|
||||
ADD COLUMN IF NOT EXISTS test_mode BOOLEAN,
|
||||
ADD COLUMN IF NOT EXISTS frm_configs jsonb,
|
||||
ADD COLUMN IF NOT EXISTS merchant_connector_id VARCHAR(32);
|
||||
ADD COLUMN IF NOT EXISTS merchant_connector_id VARCHAR(128);
|
||||
|
||||
ALTER TABLE customers
|
||||
ADD COLUMN customer_id VARCHAR(64),
|
||||
ADD COLUMN customer_id VARCHAR(64),
|
||||
ADD COLUMN address_id VARCHAR(64);
|
||||
|
||||
ALTER TABLE payment_intent
|
||||
ADD COLUMN IF NOT EXISTS payment_id VARCHAR(64) NOT NULL,
|
||||
ADD COLUMN IF NOT EXISTS payment_id VARCHAR(64),
|
||||
ADD COLUMN connector_id VARCHAR(64),
|
||||
ADD COLUMN shipping_address_id VARCHAR(64),
|
||||
ADD COLUMN billing_address_id VARCHAR(64),
|
||||
ADD COLUMN shipping_details VARCHAR(64),
|
||||
ADD COLUMN billing_details VARCHAR(64),
|
||||
ADD COLUMN shipping_details BYTEA,
|
||||
ADD COLUMN billing_details BYTEA,
|
||||
ADD COLUMN statement_descriptor_suffix VARCHAR(255),
|
||||
ADD COLUMN business_country "CountryAlpha2",
|
||||
ADD COLUMN business_label VARCHAR(64),
|
||||
@ -69,14 +66,15 @@ ADD COLUMN IF NOT EXISTS payment_id VARCHAR(64) NOT NULL,
|
||||
ADD COLUMN charges jsonb;
|
||||
|
||||
ALTER TABLE payment_attempt
|
||||
ADD COLUMN IF NOT EXISTS attempt_id VARCHAR(64) NOT NULL,
|
||||
ADD COLUMN amount bigint NOT NULL,
|
||||
ADD COLUMN IF NOT EXISTS attempt_id VARCHAR(64),
|
||||
ADD COLUMN amount bigint,
|
||||
ADD COLUMN currency "Currency",
|
||||
ADD COLUMN save_to_locker BOOLEAN,
|
||||
ADD COLUMN offer_amount bigint,
|
||||
ADD COLUMN payment_method VARCHAR,
|
||||
ADD COLUMN connector_transaction_id VARCHAR(64),
|
||||
ADD COLUMN connector_transaction_data TEXT,
|
||||
ADD COLUMN connector_transaction_id VARCHAR(128),
|
||||
ADD COLUMN connector_transaction_data VARCHAR(512),
|
||||
ADD COLUMN processor_transaction_data text,
|
||||
ADD COLUMN capture_method "CaptureMethod",
|
||||
ADD COLUMN capture_on TIMESTAMP,
|
||||
ADD COLUMN mandate_id VARCHAR(64),
|
||||
@ -87,7 +85,7 @@ ADD COLUMN IF NOT EXISTS attempt_id VARCHAR(64) NOT NULL,
|
||||
ADD COLUMN tax_amount bigint,
|
||||
ADD COLUMN straight_through_algorithm JSONB,
|
||||
ADD COLUMN confirm BOOLEAN,
|
||||
ADD COLUMN authentication_data JSONB,
|
||||
ADD COLUMN authentication_data JSON,
|
||||
ADD COLUMN payment_method_billing_address_id VARCHAR(64),
|
||||
ADD COLUMN connector_mandate_detail JSONB,
|
||||
ADD COLUMN charge_id VARCHAR(64);
|
||||
@ -96,3 +94,40 @@ ADD COLUMN IF NOT EXISTS attempt_id VARCHAR(64) NOT NULL,
|
||||
CREATE INDEX payment_attempt_connector_transaction_id_merchant_id_index ON payment_attempt (connector_transaction_id, merchant_id);
|
||||
|
||||
CREATE UNIQUE INDEX payment_attempt_payment_id_merchant_id_attempt_id_index ON payment_attempt (payment_id, merchant_id, attempt_id);
|
||||
|
||||
-- Payment Methods
|
||||
CREATE TYPE "PaymentMethodIssuerCode" AS ENUM (
|
||||
'jp_hdfc',
|
||||
'jp_icici',
|
||||
'jp_googlepay',
|
||||
'jp_applepay',
|
||||
'jp_phonepe',
|
||||
'jp_wechat',
|
||||
'jp_sofort',
|
||||
'jp_giropay',
|
||||
'jp_sepa',
|
||||
'jp_bacs'
|
||||
);
|
||||
|
||||
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 payer_country TEXT [ ],
|
||||
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";
|
||||
|
||||
ALTER TABLE refund ADD COLUMN connector_refund_data VARCHAR(512),
|
||||
ADD COLUMN connector_transaction_data VARCHAR(512);
|
||||
|
||||
ALTER TABLE captures ADD COLUMN connector_capture_data VARCHAR(512);
|
||||
@ -91,6 +91,26 @@ ALTER TABLE payment_attempt DROP COLUMN attempt_id,
|
||||
DROP COLUMN connector_mandate_detail,
|
||||
DROP COLUMN charge_id;
|
||||
|
||||
|
||||
ALTER TABLE payment_methods
|
||||
DROP COLUMN IF EXISTS payment_method_id,
|
||||
DROP COLUMN IF EXISTS accepted_currency,
|
||||
DROP COLUMN IF EXISTS scheme,
|
||||
DROP COLUMN IF EXISTS token,
|
||||
DROP COLUMN IF EXISTS cardholder_name,
|
||||
DROP COLUMN IF EXISTS issuer_name,
|
||||
DROP COLUMN IF EXISTS issuer_country,
|
||||
DROP COLUMN IF EXISTS payer_country,
|
||||
DROP COLUMN IF EXISTS is_stored,
|
||||
DROP COLUMN IF EXISTS direct_debit_token,
|
||||
DROP COLUMN IF EXISTS swift_code,
|
||||
DROP COLUMN IF EXISTS payment_method_issuer,
|
||||
DROP COLUMN IF EXISTS payment_method_issuer_code,
|
||||
DROP COLUMN IF EXISTS metadata,
|
||||
DROP COLUMN IF EXISTS payment_method,
|
||||
DROP COLUMN IF EXISTS payment_method_type;
|
||||
DROP TYPE IF EXISTS "PaymentMethodIssuerCode";
|
||||
|
||||
-- Run below queries only when V1 is deprecated
|
||||
ALTER TABLE refund DROP COLUMN connector_refund_data,
|
||||
DROP COLUMN connector_transaction_data;
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE merchant_connector_account
|
||||
ALTER COLUMN payment_methods_enabled TYPE JSON [ ];
|
||||
@ -0,0 +1,3 @@
|
||||
-- Your SQL goes here
|
||||
ALTER TABLE merchant_connector_account
|
||||
ALTER COLUMN payment_methods_enabled TYPE JSONB [ ];
|
||||
@ -1,3 +0,0 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE business_profile
|
||||
DROP COLUMN IF EXISTS three_ds_decision_manager_config;
|
||||
@ -1,3 +0,0 @@
|
||||
-- Your SQL goes here
|
||||
ALTER TABLE business_profile
|
||||
ADD COLUMN IF NOT EXISTS three_ds_decision_manager_config jsonb;
|
||||
@ -1,2 +0,0 @@
|
||||
ALTER TABLE merchant_connector_account
|
||||
DROP COLUMN IF EXISTS feature_metadata;
|
||||
@ -1,2 +0,0 @@
|
||||
ALTER TABLE merchant_connector_account
|
||||
ADD COLUMN feature_metadata JSONB;
|
||||
Reference in New Issue
Block a user