mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-01 19:42:27 +08:00
refactor(accounts): move accounts related tables to accounts schema (#7626)
This commit is contained in:
@ -161,7 +161,14 @@ pub trait GlobalStorageInterface:
|
||||
|
||||
#[async_trait::async_trait]
|
||||
pub trait AccountsStorageInterface:
|
||||
Send + Sync + dyn_clone::DynClone + OrganizationInterface + 'static
|
||||
Send
|
||||
+ Sync
|
||||
+ dyn_clone::DynClone
|
||||
+ OrganizationInterface
|
||||
+ merchant_account::MerchantAccountInterface
|
||||
+ business_profile::ProfileInterface
|
||||
+ merchant_connector_account::MerchantConnectorAccountInterface
|
||||
+ 'static
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -82,7 +82,7 @@ impl ProfileInterface for Store {
|
||||
merchant_key_store: &domain::MerchantKeyStore,
|
||||
business_profile: domain::Profile,
|
||||
) -> CustomResult<domain::Profile, errors::StorageError> {
|
||||
let conn = connection::pg_connection_write(self).await?;
|
||||
let conn = connection::pg_accounts_connection_write(self).await?;
|
||||
business_profile
|
||||
.construct_new()
|
||||
.await
|
||||
@ -106,7 +106,7 @@ impl ProfileInterface for Store {
|
||||
merchant_key_store: &domain::MerchantKeyStore,
|
||||
profile_id: &common_utils::id_type::ProfileId,
|
||||
) -> CustomResult<domain::Profile, errors::StorageError> {
|
||||
let conn = connection::pg_connection_read(self).await?;
|
||||
let conn = connection::pg_accounts_connection_read(self).await?;
|
||||
storage::Profile::find_by_profile_id(&conn, profile_id)
|
||||
.await
|
||||
.map_err(|error| report!(errors::StorageError::from(error)))?
|
||||
@ -126,7 +126,7 @@ impl ProfileInterface for Store {
|
||||
merchant_id: &common_utils::id_type::MerchantId,
|
||||
profile_id: &common_utils::id_type::ProfileId,
|
||||
) -> CustomResult<domain::Profile, errors::StorageError> {
|
||||
let conn = connection::pg_connection_read(self).await?;
|
||||
let conn = connection::pg_accounts_connection_read(self).await?;
|
||||
storage::Profile::find_by_merchant_id_profile_id(&conn, merchant_id, profile_id)
|
||||
.await
|
||||
.map_err(|error| report!(errors::StorageError::from(error)))?
|
||||
@ -147,7 +147,7 @@ impl ProfileInterface for Store {
|
||||
profile_name: &str,
|
||||
merchant_id: &common_utils::id_type::MerchantId,
|
||||
) -> CustomResult<domain::Profile, errors::StorageError> {
|
||||
let conn = connection::pg_connection_read(self).await?;
|
||||
let conn = connection::pg_accounts_connection_read(self).await?;
|
||||
storage::Profile::find_by_profile_name_merchant_id(&conn, profile_name, merchant_id)
|
||||
.await
|
||||
.map_err(|error| report!(errors::StorageError::from(error)))?
|
||||
@ -168,7 +168,7 @@ impl ProfileInterface for Store {
|
||||
current_state: domain::Profile,
|
||||
profile_update: domain::ProfileUpdate,
|
||||
) -> CustomResult<domain::Profile, errors::StorageError> {
|
||||
let conn = connection::pg_connection_write(self).await?;
|
||||
let conn = connection::pg_accounts_connection_write(self).await?;
|
||||
Conversion::convert(current_state)
|
||||
.await
|
||||
.change_context(errors::StorageError::EncryptionError)?
|
||||
@ -190,7 +190,7 @@ impl ProfileInterface for Store {
|
||||
profile_id: &common_utils::id_type::ProfileId,
|
||||
merchant_id: &common_utils::id_type::MerchantId,
|
||||
) -> CustomResult<bool, errors::StorageError> {
|
||||
let conn = connection::pg_connection_write(self).await?;
|
||||
let conn = connection::pg_accounts_connection_write(self).await?;
|
||||
storage::Profile::delete_by_profile_id_merchant_id(&conn, profile_id, merchant_id)
|
||||
.await
|
||||
.map_err(|error| report!(errors::StorageError::from(error)))
|
||||
@ -203,7 +203,7 @@ impl ProfileInterface for Store {
|
||||
merchant_key_store: &domain::MerchantKeyStore,
|
||||
merchant_id: &common_utils::id_type::MerchantId,
|
||||
) -> CustomResult<Vec<domain::Profile>, errors::StorageError> {
|
||||
let conn = connection::pg_connection_read(self).await?;
|
||||
let conn = connection::pg_accounts_connection_read(self).await?;
|
||||
storage::Profile::list_profile_by_merchant_id(&conn, merchant_id)
|
||||
.await
|
||||
.map_err(|error| report!(errors::StorageError::from(error)))
|
||||
|
||||
@ -112,7 +112,7 @@ impl MerchantAccountInterface for Store {
|
||||
merchant_account: domain::MerchantAccount,
|
||||
merchant_key_store: &domain::MerchantKeyStore,
|
||||
) -> CustomResult<domain::MerchantAccount, errors::StorageError> {
|
||||
let conn = connection::pg_connection_write(self).await?;
|
||||
let conn = connection::pg_accounts_connection_write(self).await?;
|
||||
merchant_account
|
||||
.construct_new()
|
||||
.await
|
||||
@ -137,7 +137,7 @@ impl MerchantAccountInterface for Store {
|
||||
merchant_key_store: &domain::MerchantKeyStore,
|
||||
) -> CustomResult<domain::MerchantAccount, errors::StorageError> {
|
||||
let fetch_func = || async {
|
||||
let conn = connection::pg_connection_read(self).await?;
|
||||
let conn = connection::pg_accounts_connection_read(self).await?;
|
||||
storage::MerchantAccount::find_by_merchant_id(&conn, merchant_id)
|
||||
.await
|
||||
.map_err(|error| report!(errors::StorageError::from(error)))
|
||||
@ -183,7 +183,7 @@ impl MerchantAccountInterface for Store {
|
||||
merchant_account: storage::MerchantAccountUpdate,
|
||||
merchant_key_store: &domain::MerchantKeyStore,
|
||||
) -> CustomResult<domain::MerchantAccount, errors::StorageError> {
|
||||
let conn = connection::pg_connection_write(self).await?;
|
||||
let conn = connection::pg_accounts_connection_write(self).await?;
|
||||
|
||||
let updated_merchant_account = Conversion::convert(this)
|
||||
.await
|
||||
@ -214,7 +214,7 @@ impl MerchantAccountInterface for Store {
|
||||
merchant_account: storage::MerchantAccountUpdate,
|
||||
merchant_key_store: &domain::MerchantKeyStore,
|
||||
) -> CustomResult<domain::MerchantAccount, errors::StorageError> {
|
||||
let conn = connection::pg_connection_write(self).await?;
|
||||
let conn = connection::pg_accounts_connection_write(self).await?;
|
||||
let updated_merchant_account = storage::MerchantAccount::update_with_specific_fields(
|
||||
&conn,
|
||||
merchant_id,
|
||||
@ -245,7 +245,7 @@ impl MerchantAccountInterface for Store {
|
||||
) -> CustomResult<(domain::MerchantAccount, domain::MerchantKeyStore), errors::StorageError>
|
||||
{
|
||||
let fetch_by_pub_key_func = || async {
|
||||
let conn = connection::pg_connection_read(self).await?;
|
||||
let conn = connection::pg_accounts_connection_read(self).await?;
|
||||
|
||||
storage::MerchantAccount::find_by_publishable_key(&conn, publishable_key)
|
||||
.await
|
||||
@ -294,7 +294,7 @@ impl MerchantAccountInterface for Store {
|
||||
organization_id: &common_utils::id_type::OrganizationId,
|
||||
) -> CustomResult<Vec<domain::MerchantAccount>, errors::StorageError> {
|
||||
use futures::future::try_join_all;
|
||||
let conn = connection::pg_connection_read(self).await?;
|
||||
let conn = connection::pg_accounts_connection_read(self).await?;
|
||||
|
||||
let encrypted_merchant_accounts =
|
||||
storage::MerchantAccount::list_by_organization_id(&conn, organization_id)
|
||||
@ -338,7 +338,7 @@ impl MerchantAccountInterface for Store {
|
||||
&self,
|
||||
merchant_id: &common_utils::id_type::MerchantId,
|
||||
) -> CustomResult<bool, errors::StorageError> {
|
||||
let conn = connection::pg_connection_write(self).await?;
|
||||
let conn = connection::pg_accounts_connection_write(self).await?;
|
||||
|
||||
let is_deleted_func = || async {
|
||||
storage::MerchantAccount::delete_by_merchant_id(&conn, merchant_id)
|
||||
@ -375,7 +375,7 @@ impl MerchantAccountInterface for Store {
|
||||
state: &KeyManagerState,
|
||||
merchant_ids: Vec<common_utils::id_type::MerchantId>,
|
||||
) -> CustomResult<Vec<domain::MerchantAccount>, errors::StorageError> {
|
||||
let conn = connection::pg_connection_read(self).await?;
|
||||
let conn = connection::pg_accounts_connection_read(self).await?;
|
||||
|
||||
let encrypted_merchant_accounts =
|
||||
storage::MerchantAccount::list_multiple_merchant_accounts(&conn, merchant_ids)
|
||||
@ -439,7 +439,7 @@ impl MerchantAccountInterface for Store {
|
||||
)>,
|
||||
errors::StorageError,
|
||||
> {
|
||||
let conn = connection::pg_connection_read(self).await?;
|
||||
let conn = connection::pg_accounts_connection_read(self).await?;
|
||||
let encrypted_merchant_accounts =
|
||||
storage::MerchantAccount::list_all_merchant_accounts(&conn, limit, offset)
|
||||
.await
|
||||
@ -460,7 +460,7 @@ impl MerchantAccountInterface for Store {
|
||||
&self,
|
||||
merchant_account: storage::MerchantAccountUpdate,
|
||||
) -> CustomResult<usize, errors::StorageError> {
|
||||
let conn = connection::pg_connection_read(self).await?;
|
||||
let conn = connection::pg_accounts_connection_read(self).await?;
|
||||
|
||||
let db_func = || async {
|
||||
storage::MerchantAccount::update_all_merchant_accounts(
|
||||
|
||||
@ -240,7 +240,7 @@ impl MerchantConnectorAccountInterface for Store {
|
||||
key_store: &domain::MerchantKeyStore,
|
||||
) -> CustomResult<domain::MerchantConnectorAccount, errors::StorageError> {
|
||||
let find_call = || async {
|
||||
let conn = connection::pg_connection_read(self).await?;
|
||||
let conn = connection::pg_accounts_connection_read(self).await?;
|
||||
storage::MerchantConnectorAccount::find_by_merchant_id_connector(
|
||||
&conn,
|
||||
merchant_id,
|
||||
@ -291,7 +291,7 @@ impl MerchantConnectorAccountInterface for Store {
|
||||
key_store: &domain::MerchantKeyStore,
|
||||
) -> CustomResult<domain::MerchantConnectorAccount, errors::StorageError> {
|
||||
let find_call = || async {
|
||||
let conn = connection::pg_connection_read(self).await?;
|
||||
let conn = connection::pg_accounts_connection_read(self).await?;
|
||||
storage::MerchantConnectorAccount::find_by_profile_id_connector_name(
|
||||
&conn,
|
||||
profile_id,
|
||||
@ -345,7 +345,7 @@ impl MerchantConnectorAccountInterface for Store {
|
||||
connector_name: &str,
|
||||
key_store: &domain::MerchantKeyStore,
|
||||
) -> CustomResult<Vec<domain::MerchantConnectorAccount>, errors::StorageError> {
|
||||
let conn = connection::pg_connection_read(self).await?;
|
||||
let conn = connection::pg_accounts_connection_read(self).await?;
|
||||
storage::MerchantConnectorAccount::find_by_merchant_id_connector_name(
|
||||
&conn,
|
||||
merchant_id,
|
||||
@ -381,7 +381,7 @@ impl MerchantConnectorAccountInterface for Store {
|
||||
key_store: &domain::MerchantKeyStore,
|
||||
) -> CustomResult<domain::MerchantConnectorAccount, errors::StorageError> {
|
||||
let find_call = || async {
|
||||
let conn = connection::pg_connection_read(self).await?;
|
||||
let conn = connection::pg_accounts_connection_read(self).await?;
|
||||
storage::MerchantConnectorAccount::find_by_merchant_id_merchant_connector_id(
|
||||
&conn,
|
||||
merchant_id,
|
||||
@ -436,7 +436,7 @@ impl MerchantConnectorAccountInterface for Store {
|
||||
key_store: &domain::MerchantKeyStore,
|
||||
) -> CustomResult<domain::MerchantConnectorAccount, errors::StorageError> {
|
||||
let find_call = || async {
|
||||
let conn = connection::pg_connection_read(self).await?;
|
||||
let conn = connection::pg_accounts_connection_read(self).await?;
|
||||
storage::MerchantConnectorAccount::find_by_id(&conn, id)
|
||||
.await
|
||||
.map_err(|error| report!(errors::StorageError::from(error)))
|
||||
@ -483,7 +483,7 @@ impl MerchantConnectorAccountInterface for Store {
|
||||
t: domain::MerchantConnectorAccount,
|
||||
key_store: &domain::MerchantKeyStore,
|
||||
) -> CustomResult<domain::MerchantConnectorAccount, errors::StorageError> {
|
||||
let conn = connection::pg_connection_write(self).await?;
|
||||
let conn = connection::pg_accounts_connection_write(self).await?;
|
||||
t.construct_new()
|
||||
.await
|
||||
.change_context(errors::StorageError::EncryptionError)?
|
||||
@ -510,7 +510,7 @@ impl MerchantConnectorAccountInterface for Store {
|
||||
key_store: &domain::MerchantKeyStore,
|
||||
connector_type: common_enums::ConnectorType,
|
||||
) -> CustomResult<Vec<domain::MerchantConnectorAccount>, errors::StorageError> {
|
||||
let conn = connection::pg_connection_read(self).await?;
|
||||
let conn = connection::pg_accounts_connection_read(self).await?;
|
||||
|
||||
storage::MerchantConnectorAccount::list_enabled_by_profile_id(
|
||||
&conn,
|
||||
@ -545,7 +545,7 @@ impl MerchantConnectorAccountInterface for Store {
|
||||
get_disabled: bool,
|
||||
key_store: &domain::MerchantKeyStore,
|
||||
) -> CustomResult<domain::MerchantConnectorAccounts, errors::StorageError> {
|
||||
let conn = connection::pg_connection_read(self).await?;
|
||||
let conn = connection::pg_accounts_connection_read(self).await?;
|
||||
let merchant_connector_account_vec =
|
||||
storage::MerchantConnectorAccount::find_by_merchant_id(
|
||||
&conn,
|
||||
@ -583,7 +583,7 @@ impl MerchantConnectorAccountInterface for Store {
|
||||
profile_id: &common_utils::id_type::ProfileId,
|
||||
key_store: &domain::MerchantKeyStore,
|
||||
) -> CustomResult<Vec<domain::MerchantConnectorAccount>, errors::StorageError> {
|
||||
let conn = connection::pg_connection_read(self).await?;
|
||||
let conn = connection::pg_accounts_connection_read(self).await?;
|
||||
storage::MerchantConnectorAccount::list_by_profile_id(&conn, profile_id)
|
||||
.await
|
||||
.map_err(|error| report!(errors::StorageError::from(error)))
|
||||
@ -613,7 +613,7 @@ impl MerchantConnectorAccountInterface for Store {
|
||||
storage::MerchantConnectorAccountUpdateInternal,
|
||||
)>,
|
||||
) -> CustomResult<(), errors::StorageError> {
|
||||
let conn = connection::pg_connection_write(self).await?;
|
||||
let conn = connection::pg_accounts_connection_write(self).await?;
|
||||
|
||||
async fn update_call(
|
||||
connection: &diesel_models::PgPooledConn,
|
||||
@ -731,7 +731,7 @@ impl MerchantConnectorAccountInterface for Store {
|
||||
let _merchant_connector_id = this.merchant_connector_id.clone();
|
||||
|
||||
let update_call = || async {
|
||||
let conn = connection::pg_connection_write(self).await?;
|
||||
let conn = connection::pg_accounts_connection_write(self).await?;
|
||||
Conversion::convert(this)
|
||||
.await
|
||||
.change_context(errors::StorageError::EncryptionError)?
|
||||
@ -811,7 +811,7 @@ impl MerchantConnectorAccountInterface for Store {
|
||||
let _merchant_connector_id = this.get_id().clone();
|
||||
|
||||
let update_call = || async {
|
||||
let conn = connection::pg_connection_write(self).await?;
|
||||
let conn = connection::pg_accounts_connection_write(self).await?;
|
||||
Conversion::convert(this)
|
||||
.await
|
||||
.change_context(errors::StorageError::EncryptionError)?
|
||||
@ -879,7 +879,7 @@ impl MerchantConnectorAccountInterface for Store {
|
||||
merchant_id: &common_utils::id_type::MerchantId,
|
||||
merchant_connector_id: &common_utils::id_type::MerchantConnectorAccountId,
|
||||
) -> CustomResult<bool, errors::StorageError> {
|
||||
let conn = connection::pg_connection_write(self).await?;
|
||||
let conn = connection::pg_accounts_connection_write(self).await?;
|
||||
let delete_call = || async {
|
||||
storage::MerchantConnectorAccount::delete_by_merchant_id_merchant_connector_id(
|
||||
&conn,
|
||||
@ -954,7 +954,7 @@ impl MerchantConnectorAccountInterface for Store {
|
||||
&self,
|
||||
id: &common_utils::id_type::MerchantConnectorAccountId,
|
||||
) -> CustomResult<bool, errors::StorageError> {
|
||||
let conn = connection::pg_connection_write(self).await?;
|
||||
let conn = connection::pg_accounts_connection_write(self).await?;
|
||||
let delete_call = || async {
|
||||
storage::MerchantConnectorAccount::delete_by_id(&conn, id)
|
||||
.await
|
||||
@ -1240,7 +1240,8 @@ impl MerchantConnectorAccountInterface for MockDb {
|
||||
connector_account_details: t.connector_account_details.into(),
|
||||
test_mode: t.test_mode,
|
||||
disabled: t.disabled,
|
||||
merchant_connector_id: t.merchant_connector_id,
|
||||
merchant_connector_id: t.merchant_connector_id.clone(),
|
||||
id: Some(t.merchant_connector_id),
|
||||
payment_methods_enabled: t.payment_methods_enabled,
|
||||
metadata: t.metadata,
|
||||
frm_configs: None,
|
||||
|
||||
Reference in New Issue
Block a user