diff --git a/Cargo.lock b/Cargo.lock index 75069b45770..e1edaedfd03 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2784,7 +2784,7 @@ dependencies = [ [[package]] name = "opentelemetry" version = "0.18.0" -source = "git+https://github.com/open-telemetry/opentelemetry-rust?rev=44b90202fd744598db8b0ace5b8f0bad7ec45658#44b90202fd744598db8b0ace5b8f0bad7ec45658" +source = "git+https://github.com/open-telemetry/opentelemetry-rust/?rev=44b90202fd744598db8b0ace5b8f0bad7ec45658#44b90202fd744598db8b0ace5b8f0bad7ec45658" dependencies = [ "opentelemetry_api", "opentelemetry_sdk", @@ -2793,7 +2793,7 @@ dependencies = [ [[package]] name = "opentelemetry-otlp" version = "0.11.0" -source = "git+https://github.com/open-telemetry/opentelemetry-rust?rev=44b90202fd744598db8b0ace5b8f0bad7ec45658#44b90202fd744598db8b0ace5b8f0bad7ec45658" +source = "git+https://github.com/open-telemetry/opentelemetry-rust/?rev=44b90202fd744598db8b0ace5b8f0bad7ec45658#44b90202fd744598db8b0ace5b8f0bad7ec45658" dependencies = [ "async-trait", "futures", @@ -2810,7 +2810,7 @@ dependencies = [ [[package]] name = "opentelemetry-proto" version = "0.1.0" -source = "git+https://github.com/open-telemetry/opentelemetry-rust?rev=44b90202fd744598db8b0ace5b8f0bad7ec45658#44b90202fd744598db8b0ace5b8f0bad7ec45658" +source = "git+https://github.com/open-telemetry/opentelemetry-rust/?rev=44b90202fd744598db8b0ace5b8f0bad7ec45658#44b90202fd744598db8b0ace5b8f0bad7ec45658" dependencies = [ "futures", "futures-util", @@ -2822,7 +2822,7 @@ dependencies = [ [[package]] name = "opentelemetry_api" version = "0.18.0" -source = "git+https://github.com/open-telemetry/opentelemetry-rust?rev=44b90202fd744598db8b0ace5b8f0bad7ec45658#44b90202fd744598db8b0ace5b8f0bad7ec45658" +source = "git+https://github.com/open-telemetry/opentelemetry-rust/?rev=44b90202fd744598db8b0ace5b8f0bad7ec45658#44b90202fd744598db8b0ace5b8f0bad7ec45658" dependencies = [ "fnv", "futures-channel", @@ -2837,7 +2837,7 @@ dependencies = [ [[package]] name = "opentelemetry_sdk" version = "0.18.0" -source = "git+https://github.com/open-telemetry/opentelemetry-rust?rev=44b90202fd744598db8b0ace5b8f0bad7ec45658#44b90202fd744598db8b0ace5b8f0bad7ec45658" +source = "git+https://github.com/open-telemetry/opentelemetry-rust/?rev=44b90202fd744598db8b0ace5b8f0bad7ec45658#44b90202fd744598db8b0ace5b8f0bad7ec45658" dependencies = [ "async-trait", "crossbeam-channel", diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs index 977cdf2e6d3..7f41594a5fb 100644 --- a/crates/router/src/core/payments.rs +++ b/crates/router/src/core/payments.rs @@ -828,7 +828,7 @@ pub async fn list_payments( ) -> RouterResponse { use futures::stream::StreamExt; - use crate::types::transformers::ForeignTryFrom; + use crate::types::transformers::ForeignFrom; helpers::validate_payment_list_request(&constraints)?; let merchant_id = &merchant.merchant_id; @@ -859,11 +859,7 @@ pub async fn list_payments( .collect::>() .await; - let data: Vec = pi - .into_iter() - .map(ForeignTryFrom::foreign_try_from) - .collect::>() - .change_context(errors::ApiErrorResponse::InternalServerError)?; + let data: Vec = pi.into_iter().map(ForeignFrom::foreign_from).collect(); Ok(services::ApplicationResponse::Json( api::PaymentListResponse { @@ -912,24 +908,12 @@ pub fn update_straight_through_routing( where F: Send + Clone, { - let mut routing_data: storage::RoutingData = payment_data - .payment_attempt - .connector + let _: api::RoutingAlgorithm = request_straight_through .clone() - .unwrap_or_else(|| serde_json::json!({})) - .parse_value("RoutingData") - .attach_printable("Invalid routing data format in payment attempt")?; - - let request_straight_through: api::RoutingAlgorithm = request_straight_through .parse_value("RoutingAlgorithm") .attach_printable("Invalid straight through routing rules format")?; - routing_data.algorithm = Some(request_straight_through); - - let encoded_routing_data = Encode::::encode_to_value(&routing_data) - .attach_printable("Unable to serialize routing data to serde value")?; - - payment_data.payment_attempt.connector = Some(encoded_routing_data); + payment_data.payment_attempt.straight_through_algorithm = Some(request_straight_through); Ok(()) } @@ -987,14 +971,17 @@ pub fn connector_selection( where F: Send + Clone, { - let mut routing_data: storage::RoutingData = payment_data - .payment_attempt - .connector - .clone() - .unwrap_or_else(|| serde_json::json!({})) - .parse_value("RoutingData") - .change_context(errors::ApiErrorResponse::InternalServerError) - .attach_printable("Invalid routing data format in payment attempt")?; + let mut routing_data = storage::RoutingData { + routed_through: payment_data.payment_attempt.connector.clone(), + algorithm: payment_data + .payment_attempt + .straight_through_algorithm + .clone() + .map(|val| val.parse_value("RoutingAlgorithm")) + .transpose() + .change_context(errors::ApiErrorResponse::InternalServerError) + .attach_printable("Invalid straight through algorithm format in payment attempt")?, + }; let request_straight_through: Option = request_straight_through .map(|val| val.parse_value("RoutingAlgorithm")) @@ -1009,11 +996,15 @@ where &mut routing_data, )?; - let encoded_routing_data = Encode::::encode_to_value(&routing_data) + let encoded_algorithm = routing_data + .algorithm + .map(|algo| Encode::::encode_to_value(&algo)) + .transpose() .change_context(errors::ApiErrorResponse::InternalServerError) - .attach_printable("Unable to serialize routing data to serde value")?; + .attach_printable("Unable to serialize routing algorithm to serde value")?; - payment_data.payment_attempt.connector = Some(encoded_routing_data); + payment_data.payment_attempt.connector = routing_data.routed_through; + payment_data.payment_attempt.straight_through_algorithm = encoded_algorithm; Ok(decided_connector) } diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs index 36ace8333fc..dc6c35e251a 100644 --- a/crates/router/src/core/payments/helpers.rs +++ b/crates/router/src/core/payments/helpers.rs @@ -483,14 +483,9 @@ where Op: std::fmt::Debug, { if check_if_operation_confirm(operation) { - let routed_through: storage::RoutedThroughData = payment_attempt + let connector_name = payment_attempt .connector .clone() - .parse_value("RoutedThroughData") - .change_context(errors::ApiErrorResponse::InternalServerError)?; - - let connector_name = routed_through - .routed_through .ok_or(errors::ApiErrorResponse::InternalServerError)?; let schedule_time = payment_sync::get_sync_process_schedule_time( diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rs index 632da05a58e..646e977e161 100644 --- a/crates/router/src/core/payments/operations/payment_confirm.rs +++ b/crates/router/src/core/payments/operations/payment_confirm.rs @@ -331,6 +331,10 @@ impl UpdateTracker, api::PaymentsRequest> for Paymen }; let connector = payment_data.payment_attempt.connector.clone(); + let straight_through_algorithm = payment_data + .payment_attempt + .straight_through_algorithm + .clone(); let payment_token = payment_data.token.clone(); let payment_method_type = payment_data.payment_attempt.payment_method_type.clone(); let payment_experience = payment_data.payment_attempt.payment_experience.clone(); @@ -362,6 +366,7 @@ impl UpdateTracker, api::PaymentsRequest> for Paymen payment_method_type, payment_experience, business_sub_label, + straight_through_algorithm, }, storage_scheme, ) diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rs index 945b24d155f..548b4e1e2e8 100644 --- a/crates/router/src/core/payments/operations/payment_create.rs +++ b/crates/router/src/core/payments/operations/payment_create.rs @@ -23,7 +23,6 @@ use crate::{ storage::{ self, enums::{self, IntentStatus}, - PaymentAttemptExt, }, transformers::ForeignInto, }, @@ -139,8 +138,7 @@ impl GetTracker, api::PaymentsRequest> for Pa })?; connector_response = db .insert_connector_response( - Self::make_connector_response(&payment_attempt) - .change_context(errors::ApiErrorResponse::InternalServerError)?, + Self::make_connector_response(&payment_attempt), storage_scheme, ) .await @@ -316,6 +314,10 @@ impl UpdateTracker, api::PaymentsRequest> for Paymen let payment_token = payment_data.token.clone(); let connector = payment_data.payment_attempt.connector.clone(); + let straight_through_algorithm = payment_data + .payment_attempt + .straight_through_algorithm + .clone(); payment_data.payment_attempt = db .update_payment_attempt_with_attempt_id( @@ -323,6 +325,7 @@ impl UpdateTracker, api::PaymentsRequest> for Paymen storage::PaymentAttemptUpdate::UpdateTrackers { payment_token, connector, + straight_through_algorithm, }, storage_scheme, ) @@ -532,18 +535,18 @@ impl PaymentCreate { #[instrument(skip_all)] pub fn make_connector_response( payment_attempt: &storage::PaymentAttempt, - ) -> CustomResult { - Ok(storage::ConnectorResponseNew { + ) -> storage::ConnectorResponseNew { + storage::ConnectorResponseNew { payment_id: payment_attempt.payment_id.clone(), merchant_id: payment_attempt.merchant_id.clone(), attempt_id: payment_attempt.attempt_id.clone(), created_at: payment_attempt.created_at, modified_at: payment_attempt.modified_at, - connector_name: payment_attempt.get_routed_through_connector()?, + connector_name: payment_attempt.connector.clone(), connector_transaction_id: None, authentication_data: None, encoded_data: None, - }) + } } } diff --git a/crates/router/src/core/payments/operations/payment_method_validate.rs b/crates/router/src/core/payments/operations/payment_method_validate.rs index 38ce4878be9..e3b88080b63 100644 --- a/crates/router/src/core/payments/operations/payment_method_validate.rs +++ b/crates/router/src/core/payments/operations/payment_method_validate.rs @@ -124,8 +124,7 @@ impl GetTracker, api::VerifyRequest> for Paym connector_response = match db .insert_connector_response( - PaymentCreate::make_connector_response(&payment_attempt) - .change_context(errors::ApiErrorResponse::InternalServerError)?, + PaymentCreate::make_connector_response(&payment_attempt), storage_scheme, ) .await diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs index 4804ac42be5..1e41d6d80e1 100644 --- a/crates/router/src/core/payments/transformers.rs +++ b/crates/router/src/core/payments/transformers.rs @@ -15,8 +15,8 @@ use crate::{ services::{self, RedirectForm}, types::{ self, api, - storage::{self, enums, PaymentAttemptExt}, - transformers::{ForeignInto, ForeignTryFrom}, + storage::{self, enums}, + transformers::{ForeignFrom, ForeignInto}, }, utils::{OptionExt, ValueExt}, }; @@ -278,9 +278,7 @@ where }) } let mut response: api::PaymentsResponse = Default::default(); - let routed_through = payment_attempt - .get_routed_through_connector() - .change_context(errors::ApiErrorResponse::InternalServerError)?; + let routed_through = payment_attempt.connector.clone(); let connector_label = routed_through.as_ref().map(|connector_name| { helpers::get_connector_label( @@ -417,15 +415,11 @@ where }) } -impl ForeignTryFrom<(storage::PaymentIntent, storage::PaymentAttempt)> for api::PaymentsResponse { - type Error = error_stack::Report; - - fn foreign_try_from( - item: (storage::PaymentIntent, storage::PaymentAttempt), - ) -> Result { +impl ForeignFrom<(storage::PaymentIntent, storage::PaymentAttempt)> for api::PaymentsResponse { + fn foreign_from(item: (storage::PaymentIntent, storage::PaymentAttempt)) -> Self { let pi = item.0; let pa = item.1; - Ok(Self { + Self { payment_id: Some(pi.payment_id), merchant_id: Some(pi.merchant_id), status: pi.status.foreign_into(), @@ -437,11 +431,11 @@ impl ForeignTryFrom<(storage::PaymentIntent, storage::PaymentAttempt)> for api:: description: pi.description, metadata: pi.metadata, customer_id: pi.customer_id, - connector: pa.get_routed_through_connector()?, + connector: pa.connector, payment_method: pa.payment_method.map(ForeignInto::foreign_into), payment_method_type: pa.payment_method_type.map(ForeignInto::foreign_into), ..Default::default() - }) + } } } diff --git a/crates/router/src/core/refunds.rs b/crates/router/src/core/refunds.rs index d252bfee68a..a02802e140e 100644 --- a/crates/router/src/core/refunds.rs +++ b/crates/router/src/core/refunds.rs @@ -18,7 +18,7 @@ use crate::{ types::{ self, api::{self, refunds}, - storage::{self, enums, PaymentAttemptExt, ProcessTrackerExt}, + storage::{self, enums, ProcessTrackerExt}, transformers::{ForeignFrom, ForeignInto}, }, utils::{self, OptionExt}, @@ -120,8 +120,8 @@ pub async fn trigger_refund_to_gateway( creds_identifier: Option, ) -> RouterResult { let routed_through = payment_attempt - .get_routed_through_connector() - .change_context(errors::ApiErrorResponse::InternalServerError)? + .connector + .clone() .ok_or(errors::ApiErrorResponse::InternalServerError) .into_report() .attach_printable("Failed to retrieve connector from payment attempt")?; @@ -552,8 +552,8 @@ pub async fn validate_and_create_refund( .change_context(errors::ApiErrorResponse::MaximumRefundCount)?; let connector = payment_attempt - .get_routed_through_connector() - .change_context(errors::ApiErrorResponse::InternalServerError)? + .connector + .clone() .ok_or(errors::ApiErrorResponse::InternalServerError) .into_report() .attach_printable("No connector populated in payment attempt")?; diff --git a/crates/router/src/db/payment_attempt.rs b/crates/router/src/db/payment_attempt.rs index d4bc8a16d31..51da0289f9f 100644 --- a/crates/router/src/db/payment_attempt.rs +++ b/crates/router/src/db/payment_attempt.rs @@ -264,6 +264,7 @@ impl PaymentAttemptInterface for MockDb { payment_method_type: payment_attempt.payment_method_type, payment_method_data: payment_attempt.payment_method_data, business_sub_label: payment_attempt.business_sub_label, + straight_through_algorithm: payment_attempt.straight_through_algorithm, }; payment_attempts.push(payment_attempt.clone()); Ok(payment_attempt) @@ -396,6 +397,9 @@ mod storage { payment_method_type: payment_attempt.payment_method_type.clone(), payment_method_data: payment_attempt.payment_method_data.clone(), business_sub_label: payment_attempt.business_sub_label.clone(), + straight_through_algorithm: payment_attempt + .straight_through_algorithm + .clone(), }; let field = format!("pa_{}", created_attempt.attempt_id); diff --git a/crates/router/src/scheduler/workflows/payment_sync.rs b/crates/router/src/scheduler/workflows/payment_sync.rs index 7445cb0e149..d0e70c3d588 100644 --- a/crates/router/src/scheduler/workflows/payment_sync.rs +++ b/crates/router/src/scheduler/workflows/payment_sync.rs @@ -9,7 +9,7 @@ use crate::{ scheduler::{consumer, process_data, utils}, types::{ api, - storage::{self, enums, PaymentAttemptExt, ProcessTrackerExt}, + storage::{self, enums, ProcessTrackerExt}, }, utils::{OptionExt, ValueExt}, }; @@ -64,8 +64,7 @@ impl ProcessTrackerWorkflow for PaymentsSyncWorkflow { _ => { let connector = payment_data .payment_attempt - .get_routed_through_connector() - .map_err(errors::ProcessTrackerError::EParsingError)? + .connector .ok_or(errors::ProcessTrackerError::MissingRequiredField)?; retry_sync_task( diff --git a/crates/router/src/types/storage/payment_attempt.rs b/crates/router/src/types/storage/payment_attempt.rs index 5a57998b185..31e2126d2cb 100644 --- a/crates/router/src/types/storage/payment_attempt.rs +++ b/crates/router/src/types/storage/payment_attempt.rs @@ -1,43 +1,13 @@ -use error_stack::ResultExt; pub use storage_models::payment_attempt::{ PaymentAttempt, PaymentAttemptNew, PaymentAttemptUpdate, PaymentAttemptUpdateInternal, }; -use crate::{ - core::errors::{self, CustomResult}, - utils::ValueExt, -}; - #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] pub struct RoutingData { pub routed_through: Option, pub algorithm: Option, } -#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] -pub struct RoutedThroughData { - pub routed_through: Option, -} - -pub trait PaymentAttemptExt { - fn get_routed_through_connector(&self) -> CustomResult, errors::ParsingError>; -} - -impl PaymentAttemptExt for PaymentAttempt { - fn get_routed_through_connector(&self) -> CustomResult, errors::ParsingError> { - if let Some(ref val) = self.connector { - let data: RoutedThroughData = val - .clone() - .parse_value("RoutedThroughData") - .attach_printable("Failed to read routed_through connector from payment attempt")?; - - Ok(data.routed_through) - } else { - Ok(None) - } - } -} - #[cfg(feature = "kv_store")] impl crate::utils::storage_partitioning::KvStorePartition for PaymentAttempt {} @@ -67,9 +37,7 @@ mod tests { let connector = types::Connector::Dummy.to_string(); let payment_attempt = PaymentAttemptNew { payment_id: payment_id.clone(), - connector: Some(serde_json::json!({ - "routed_through": connector, - })), + connector: Some(connector), created_at: current_time.into(), modified_at: current_time.into(), ..PaymentAttemptNew::default() @@ -102,9 +70,7 @@ mod tests { let payment_attempt = PaymentAttemptNew { payment_id: payment_id.clone(), merchant_id: merchant_id.clone(), - connector: Some(serde_json::json!({ - "routed_through": connector, - })), + connector: Some(connector), created_at: current_time.into(), modified_at: current_time.into(), attempt_id: attempt_id.clone(), @@ -146,9 +112,7 @@ mod tests { let payment_attempt = PaymentAttemptNew { payment_id: uuid.clone(), merchant_id: "1".to_string(), - connector: Some(serde_json::json!({ - "routed_through": connector, - })), + connector: Some(connector), created_at: current_time.into(), modified_at: current_time.into(), // Adding a mandate_id diff --git a/crates/storage_models/src/payment_attempt.rs b/crates/storage_models/src/payment_attempt.rs index 775883f5574..61d4f400a61 100644 --- a/crates/storage_models/src/payment_attempt.rs +++ b/crates/storage_models/src/payment_attempt.rs @@ -15,7 +15,7 @@ pub struct PaymentAttempt { pub amount: i64, pub currency: Option, pub save_to_locker: Option, - pub connector: Option, + pub connector: Option, pub error_message: Option, pub offer_amount: Option, pub surcharge_amount: Option, @@ -45,6 +45,7 @@ pub struct PaymentAttempt { pub payment_method_type: Option, pub payment_method_data: Option, pub business_sub_label: Option, + pub straight_through_algorithm: Option, } #[derive( @@ -60,7 +61,7 @@ pub struct PaymentAttemptNew { pub currency: Option, // pub auto_capture: Option, pub save_to_locker: Option, - pub connector: Option, + pub connector: Option, pub error_message: Option, pub offer_amount: Option, pub surcharge_amount: Option, @@ -90,6 +91,7 @@ pub struct PaymentAttemptNew { pub payment_method_type: Option, pub payment_method_data: Option, pub business_sub_label: Option, + pub straight_through_algorithm: Option, } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -108,7 +110,8 @@ pub enum PaymentAttemptUpdate { }, UpdateTrackers { payment_token: Option, - connector: Option, + connector: Option, + straight_through_algorithm: Option, }, AuthenticationTypeUpdate { authentication_type: storage_enums::AuthenticationType, @@ -120,12 +123,13 @@ pub enum PaymentAttemptUpdate { authentication_type: Option, payment_method: Option, browser_info: Option, - connector: Option, + connector: Option, payment_token: Option, payment_method_data: Option, payment_method_type: Option, payment_experience: Option, business_sub_label: Option, + straight_through_algorithm: Option, }, VoidUpdate { status: storage_enums::AttemptStatus, @@ -133,7 +137,7 @@ pub enum PaymentAttemptUpdate { }, ResponseUpdate { status: storage_enums::AttemptStatus, - connector: Option, + connector: Option, connector_transaction_id: Option, authentication_type: Option, payment_method_id: Option>, @@ -145,7 +149,7 @@ pub enum PaymentAttemptUpdate { }, UnresolvedResponseUpdate { status: storage_enums::AttemptStatus, - connector: Option, + connector: Option, connector_transaction_id: Option, payment_method_id: Option>, error_code: Option>, @@ -155,7 +159,7 @@ pub enum PaymentAttemptUpdate { status: storage_enums::AttemptStatus, }, ErrorUpdate { - connector: Option, + connector: Option, status: storage_enums::AttemptStatus, error_code: Option>, error_message: Option>, @@ -169,7 +173,7 @@ pub struct PaymentAttemptUpdateInternal { currency: Option, status: Option, connector_transaction_id: Option, - connector: Option, + connector: Option, authentication_type: Option, payment_method: Option, error_message: Option>, @@ -185,6 +189,7 @@ pub struct PaymentAttemptUpdateInternal { payment_method_type: Option, payment_experience: Option, business_sub_label: Option, + straight_through_algorithm: Option, } impl PaymentAttemptUpdate { @@ -262,6 +267,7 @@ impl From for PaymentAttemptUpdateInternal { payment_method_type, payment_experience, business_sub_label, + straight_through_algorithm, } => Self { amount: Some(amount), currency: Some(currency), @@ -276,6 +282,7 @@ impl From for PaymentAttemptUpdateInternal { payment_method_type, payment_experience, business_sub_label, + straight_through_algorithm, ..Default::default() }, PaymentAttemptUpdate::VoidUpdate { @@ -331,9 +338,11 @@ impl From for PaymentAttemptUpdateInternal { PaymentAttemptUpdate::UpdateTrackers { payment_token, connector, + straight_through_algorithm, } => Self { payment_token, connector, + straight_through_algorithm, ..Default::default() }, PaymentAttemptUpdate::UnresolvedResponseUpdate { diff --git a/crates/storage_models/src/schema.rs b/crates/storage_models/src/schema.rs index 4c59ceb6f28..1a2992f2b7b 100644 --- a/crates/storage_models/src/schema.rs +++ b/crates/storage_models/src/schema.rs @@ -262,7 +262,7 @@ diesel::table! { amount -> Int8, currency -> Nullable, save_to_locker -> Nullable, - connector -> Nullable, + connector -> Nullable, error_message -> Nullable, offer_amount -> Nullable, surcharge_amount -> Nullable, @@ -288,6 +288,7 @@ diesel::table! { payment_method_type -> Nullable, payment_method_data -> Nullable, business_sub_label -> Nullable, + straight_through_algorithm -> Nullable, } } diff --git a/migrations/2023-04-12-075449_separate_payment_attempt_algorithm_col/down.sql b/migrations/2023-04-12-075449_separate_payment_attempt_algorithm_col/down.sql new file mode 100644 index 00000000000..63aeba1d015 --- /dev/null +++ b/migrations/2023-04-12-075449_separate_payment_attempt_algorithm_col/down.sql @@ -0,0 +1,9 @@ +-- This file should undo anything in `up.sql` +ALTER TABLE payment_attempt +ALTER COLUMN connector TYPE JSONB +USING jsonb_build_object( + 'routed_through', connector, + 'algorithm', straight_through_algorithm +); + +ALTER TABLE payment_attempt DROP COLUMN straight_through_algorithm; diff --git a/migrations/2023-04-12-075449_separate_payment_attempt_algorithm_col/up.sql b/migrations/2023-04-12-075449_separate_payment_attempt_algorithm_col/up.sql new file mode 100644 index 00000000000..8c3d34447e7 --- /dev/null +++ b/migrations/2023-04-12-075449_separate_payment_attempt_algorithm_col/up.sql @@ -0,0 +1,10 @@ +-- Your SQL goes here +ALTER TABLE payment_attempt +ADD COLUMN straight_through_algorithm JSONB; + +UPDATE payment_attempt SET straight_through_algorithm = connector->'algorithm' +WHERE connector->>'algorithm' IS NOT NULL; + +ALTER TABLE payment_attempt +ALTER COLUMN connector TYPE VARCHAR(64) +USING connector->>'routed_through';