refactor(core): patch file for removal of id from schema (#5398)

Co-authored-by: Narayan Bhat <48803246+Narayanbhat166@users.noreply.github.com>
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Co-authored-by: Narayan Bhat <narayan.bhat@juspay.in>
This commit is contained in:
Prajjwal Kumar
2024-07-24 23:01:18 +05:30
committed by GitHub
parent 8e7de90684
commit ff3b9a2a12
37 changed files with 127 additions and 97 deletions

View File

@ -1441,7 +1441,6 @@ pub async fn create_payment_connector(
business_sub_label: req.business_sub_label.clone(),
created_at: date_time::now(),
modified_at: date_time::now(),
id: None,
connector_webhook_details: match req.connector_webhook_details {
Some(connector_webhook_details) => {
connector_webhook_details.encode_to_value(

View File

@ -170,7 +170,6 @@ impl CustomerCreateBridge for customers::CustomerRequest {
description: self.description.clone(),
phone_country_code: self.phone_country_code.clone(),
metadata: self.metadata.clone(),
id: None,
connector_customer: None,
address_id: address_from_db.clone().map(|addr| addr.address_id),
created_at: common_utils::date_time::now(),

View File

@ -362,7 +362,6 @@ pub async fn get_domain_address(
let encryptable_address = AddressDetailsWithPhone::from_encryptable(encrypted_data)
.change_context(common_utils::errors::CryptoError::EncodingFailed)?;
Ok(domain::Address {
id: None,
phone_number: encryptable_address.phone_number,
country_code: address.phone.as_ref().and_then(|a| a.country_code.clone()),
merchant_id: merchant_id.to_owned(),
@ -1680,7 +1679,6 @@ pub async fn create_customer_if_not_exist<'a, F: Clone, R>(
phone_country_code: request_customer_details.phone_country_code.clone(),
description: None,
created_at: common_utils::date_time::now(),
id: None,
metadata: None,
modified_at: common_utils::date_time::now(),
connector_customer: None,

View File

@ -654,7 +654,6 @@ pub async fn get_or_create_customer_details(
phone_country_code: customer_details.phone_country_code.to_owned(),
metadata: None,
connector_customer: None,
id: None,
created_at: common_utils::date_time::now(),
modified_at: common_utils::date_time::now(),
address_id: None,

View File

@ -571,7 +571,6 @@ mod storage {
};
let field = format!("add_{}", &address_new.address_id);
let created_address = diesel_models::Address {
id: Some(0i32),
address_id: address_new.address_id.clone(),
city: address_new.city.clone(),
country: address_new.country,

View File

@ -1,4 +1,4 @@
use error_stack::{report, ResultExt};
use error_stack::report;
use router_env::{instrument, tracing};
use super::{MockDb, Store};
@ -148,8 +148,6 @@ impl DisputeInterface for MockDb {
let now = common_utils::date_time::now();
let new_dispute = storage::Dispute {
id: i32::try_from(locked_disputes.len())
.change_context(errors::StorageError::MockDbError)?,
dispute_id: dispute.dispute_id,
amount: dispute.amount,
currency: dispute.currency,
@ -674,7 +672,6 @@ mod tests {
.await
.unwrap();
assert_eq!(created_dispute.id, updated_dispute.id);
assert_eq!(created_dispute.dispute_id, updated_dispute.dispute_id);
assert_eq!(created_dispute.amount, updated_dispute.amount);
assert_eq!(created_dispute.currency, updated_dispute.currency);
@ -751,7 +748,6 @@ mod tests {
.await
.unwrap();
assert_eq!(created_dispute.id, updated_dispute.id);
assert_eq!(created_dispute.dispute_id, updated_dispute.dispute_id);
assert_eq!(created_dispute.amount, updated_dispute.amount);
assert_eq!(created_dispute.currency, updated_dispute.currency);
@ -827,7 +823,6 @@ mod tests {
.await
.unwrap();
assert_eq!(created_dispute.id, updated_dispute.id);
assert_eq!(created_dispute.dispute_id, updated_dispute.dispute_id);
assert_eq!(created_dispute.amount, updated_dispute.amount);
assert_eq!(created_dispute.currency, updated_dispute.currency);

View File

@ -1,5 +1,4 @@
use common_utils::id_type;
use error_stack::ResultExt;
use super::MockDb;
use crate::{
@ -614,7 +613,6 @@ impl MandateInterface for MockDb {
) -> CustomResult<storage_types::Mandate, errors::StorageError> {
let mut mandates = self.mandates.lock().await;
let mandate = storage_types::Mandate {
id: i32::try_from(mandates.len()).change_context(errors::StorageError::MockDbError)?,
mandate_id: mandate_new.mandate_id.clone(),
customer_id: mandate_new.customer_id,
merchant_id: mandate_new.merchant_id,

View File

@ -858,7 +858,6 @@ impl MerchantConnectorAccountInterface for MockDb {
) -> CustomResult<domain::MerchantConnectorAccount, errors::StorageError> {
let mut accounts = self.merchant_connector_accounts.lock().await;
let account = storage::MerchantConnectorAccount {
id: i32::try_from(accounts.len()).change_context(errors::StorageError::MockDbError)?,
merchant_id: t.merchant_id,
connector_name: t.connector_name,
connector_account_details: t.connector_account_details.into(),
@ -945,7 +944,7 @@ impl MerchantConnectorAccountInterface for MockDb {
.lock()
.await
.iter_mut()
.find(|account| Some(account.id) == this.id)
.find(|account| account.merchant_connector_id == this.merchant_connector_id)
.map(|a| {
let updated =
merchant_connector_account.create_merchant_connector_account(a.clone());
@ -1097,7 +1096,6 @@ mod merchant_connector_account_cache_tests {
.unwrap();
let mca = domain::MerchantConnectorAccount {
id: Some(1),
merchant_id: merchant_id.to_owned(),
connector_name: "stripe".to_string(),
connector_account_details: domain::types::encrypt(

View File

@ -664,8 +664,6 @@ impl PaymentMethodInterface for MockDb {
let mut payment_methods = self.payment_methods.lock().await;
let payment_method = storage_types::PaymentMethod {
id: i32::try_from(payment_methods.len())
.change_context(errors::StorageError::MockDbError)?,
customer_id: payment_method_new.customer_id,
merchant_id: payment_method_new.merchant_id,
payment_method_id: payment_method_new.payment_method_id,
@ -784,7 +782,7 @@ impl PaymentMethodInterface for MockDb {
.lock()
.await
.iter_mut()
.find(|pm| pm.id == payment_method.id)
.find(|pm| pm.payment_method_id == payment_method.payment_method_id)
.map(|pm| {
let payment_method_updated =
PaymentMethodUpdateInternal::from(payment_method_update)

View File

@ -4,7 +4,6 @@ use std::collections::HashSet;
#[cfg(feature = "olap")]
use common_utils::types::MinorUnit;
use diesel_models::{errors::DatabaseError, refund::RefundUpdateInternal};
use error_stack::ResultExt;
use super::MockDb;
use crate::{
@ -372,7 +371,6 @@ mod storage {
// TODO: need to add an application generated payment attempt id to distinguish between multiple attempts for the same payment id
// Check for database presence as well Maybe use a read replica here ?
let created_refund = storage_types::Refund {
id: 0i32,
refund_id: new.refund_id.clone(),
merchant_id: new.merchant_id.clone(),
attempt_id: new.attempt_id.clone(),
@ -834,7 +832,6 @@ impl RefundInterface for MockDb {
let current_time = common_utils::date_time::now();
let refund = storage_types::Refund {
id: i32::try_from(refunds.len()).change_context(errors::StorageError::MockDbError)?,
internal_reference_id: new.internal_reference_id,
refund_id: new.refund_id,
payment_id: new.payment_id,

View File

@ -1,7 +1,7 @@
use common_enums::enums;
use common_utils::id_type;
use diesel_models::role as storage;
use error_stack::{report, ResultExt};
use error_stack::report;
use router_env::{instrument, tracing};
use super::MockDb;
@ -138,7 +138,6 @@ impl RoleInterface for MockDb {
})?
}
let role = storage::Role {
id: i32::try_from(roles.len()).change_context(errors::StorageError::MockDbError)?,
role_name: role.role_name,
role_id: role.role_id,
merchant_id: role.merchant_id,

View File

@ -1,5 +1,5 @@
use diesel_models::user as storage;
use error_stack::{report, ResultExt};
use error_stack::report;
use masking::Secret;
use router_env::{instrument, tracing};
@ -152,7 +152,6 @@ impl UserInterface for MockDb {
}
let time_now = common_utils::date_time::now();
let user = storage::User {
id: i32::try_from(users.len()).change_context(errors::StorageError::MockDbError)?,
user_id: user_data.user_id,
email: user_data.email,
name: user_data.name,

View File

@ -17,8 +17,6 @@ use super::{behaviour, types};
#[derive(Clone, Debug, serde::Serialize)]
pub struct Address {
#[serde(skip_serializing)]
pub id: Option<i32>,
pub address_id: String,
pub city: Option<String>,
pub country: Option<enums::CountryAlpha2>,
@ -161,7 +159,6 @@ impl behaviour::Conversion for Address {
async fn convert(self) -> CustomResult<Self::DstType, ValidationError> {
Ok(diesel_models::address::Address {
id: self.id,
address_id: self.address_id,
city: self.city,
country: self.country,
@ -206,7 +203,6 @@ impl behaviour::Conversion for Address {
message: "Failed while decrypting".to_string(),
})?;
Ok(Self {
id: other.id,
address_id: other.address_id,
city: other.city,
country: other.country,

View File

@ -16,7 +16,6 @@ use super::{
};
#[derive(Clone, Debug)]
pub struct MerchantConnectorAccount {
pub id: Option<i32>,
pub merchant_id: common_utils::id_type::MerchantId,
pub connector_name: String,
pub connector_account_details: Encryptable<Secret<serde_json::Value>>,
@ -74,9 +73,6 @@ impl behaviour::Conversion for MerchantConnectorAccount {
async fn convert(self) -> CustomResult<Self::DstType, ValidationError> {
Ok(
diesel_models::merchant_connector_account::MerchantConnectorAccount {
id: self.id.ok_or(ValidationError::MissingRequiredField {
field_name: "id".to_string(),
})?,
merchant_id: self.merchant_id,
connector_name: self.connector_name,
connector_account_details: self.connector_account_details.into(),
@ -113,7 +109,6 @@ impl behaviour::Conversion for MerchantConnectorAccount {
) -> CustomResult<Self, ValidationError> {
let identifier = Identifier::Merchant(other.merchant_id.clone());
Ok(Self {
id: Some(other.id),
merchant_id: other.merchant_id,
connector_name: other.connector_name,
connector_account_details: decrypt(

View File

@ -755,7 +755,6 @@ impl CustomerAddress for api_models::customers::CustomerRequest {
let encryptable_address = AddressDetailsWithPhone::from_encryptable(encrypted_data)
.change_context(common_utils::errors::CryptoError::EncodingFailed)?;
let address = domain::Address {
id: None,
city: address_details.city,
country: address_details.country,
line1: encryptable_address.line1,