Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(schema): add a new column for storing large connector transaction IDs #7017

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions crates/common_utils/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1417,7 +1417,7 @@ crate::impl_to_sql_from_sql_json!(BrowserInformation);
/// In case connector's use an identifier whose length exceeds 128 characters,
/// the hash value of such identifiers will be stored as connector_transaction_id.
/// The actual connector's identifier will be stored in a separate column -
/// connector_transaction_data or something with a similar name.
/// processor_transaction_data or something with a similar name.
#[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, AsExpression)]
#[diesel(sql_type = sql_types::Text)]
pub enum ConnectorTransactionId {
Expand All @@ -1435,7 +1435,7 @@ impl ConnectorTransactionId {
}
}

/// Implementation for forming ConnectorTransactionId and an optional string to be used for connector_transaction_id and connector_transaction_data
/// Implementation for forming ConnectorTransactionId and an optional string to be used for connector_transaction_id and processor_transaction_data
pub fn form_id_and_data(src: String) -> (Self, Option<String>) {
let txn_id = Self::from(src.clone());
match txn_id {
Expand All @@ -1453,10 +1453,10 @@ impl ConnectorTransactionId {
(Self::TxnId(id), _) => Ok(id),
(Self::HashedData(_), Some(id)) => Ok(id),
(Self::HashedData(id), None) => Err(report!(ValidationError::InvalidValue {
message: "connector_transaction_data is empty for HashedData variant".to_string(),
message: "processor_transaction_data is empty for HashedData variant".to_string(),
})
.attach_printable(format!(
"connector_transaction_data is empty for connector_transaction_id {}",
"processor_transaction_data is empty for connector_transaction_id {}",
id
))),
}
Expand Down
16 changes: 10 additions & 6 deletions crates/diesel_models/src/capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ pub struct Capture {
pub capture_sequence: i16,
// reference to the capture at connector side
pub connector_response_reference_id: Option<String>,
/// INFO: This field is deprecated and replaced by processor_capture_data
pub connector_capture_data: Option<String>,
pub processor_capture_data: Option<String>,
}

#[derive(Clone, Debug, Insertable, router_derive::DebugAsDisplay, Serialize, Deserialize)]
Expand All @@ -55,7 +57,9 @@ pub struct CaptureNew {
pub connector_capture_id: Option<ConnectorTransactionId>,
pub capture_sequence: i16,
pub connector_response_reference_id: Option<String>,
/// INFO: This field is deprecated and replaced by processor_capture_data
pub connector_capture_data: Option<String>,
pub processor_capture_data: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand All @@ -64,7 +68,7 @@ pub enum CaptureUpdate {
status: storage_enums::CaptureStatus,
connector_capture_id: Option<ConnectorTransactionId>,
connector_response_reference_id: Option<String>,
connector_capture_data: Option<String>,
processor_capture_data: Option<String>,
},
ErrorUpdate {
status: storage_enums::CaptureStatus,
Expand All @@ -84,7 +88,7 @@ pub struct CaptureUpdateInternal {
pub modified_at: Option<PrimitiveDateTime>,
pub connector_capture_id: Option<ConnectorTransactionId>,
pub connector_response_reference_id: Option<String>,
pub connector_capture_data: Option<String>,
pub processor_capture_data: Option<String>,
}

impl CaptureUpdate {
Expand All @@ -97,7 +101,7 @@ impl CaptureUpdate {
modified_at: _,
connector_capture_id,
connector_response_reference_id,
connector_capture_data,
processor_capture_data,
} = self.into();
Capture {
status: status.unwrap_or(source.status),
Expand All @@ -108,7 +112,7 @@ impl CaptureUpdate {
connector_capture_id: connector_capture_id.or(source.connector_capture_id),
connector_response_reference_id: connector_response_reference_id
.or(source.connector_response_reference_id),
connector_capture_data: connector_capture_data.or(source.connector_capture_data),
processor_capture_data: processor_capture_data.or(source.processor_capture_data),
..source
}
}
Expand All @@ -122,13 +126,13 @@ impl From<CaptureUpdate> for CaptureUpdateInternal {
status,
connector_capture_id: connector_transaction_id,
connector_response_reference_id,
connector_capture_data,
processor_capture_data,
} => Self {
status: Some(status),
connector_capture_id: connector_transaction_id,
modified_at: now,
connector_response_reference_id,
connector_capture_data,
processor_capture_data,
..Self::default()
},
CaptureUpdate::ErrorUpdate {
Expand Down
Loading