feat(date_time): add created_at and modified_at to merchant related tables (#925)

This commit is contained in:
Nishant Joshi
2023-04-21 02:51:22 +05:30
committed by GitHub
parent 22cee8cdd9
commit 1f151ba15a
9 changed files with 45 additions and 0 deletions

View File

@ -184,6 +184,7 @@ impl CustomerInterface for MockDb {
description: customer_data.description,
created_at: common_utils::date_time::now(),
metadata: customer_data.metadata,
modified_at: common_utils::date_time::now(),
};
customers.push(customer.clone());
Ok(customer)

View File

@ -199,6 +199,8 @@ impl MerchantAccountInterface for MockDb {
locker_id: merchant_account.locker_id,
metadata: merchant_account.metadata,
primary_business_details: merchant_account.primary_business_details,
created_at: common_utils::date_time::now(),
modified_at: common_utils::date_time::now(),
};
accounts.push(account.clone());
Ok(account)

View File

@ -295,6 +295,8 @@ impl MerchantConnectorAccountInterface for MockDb {
business_country: t.business_country,
business_label: t.business_label,
business_sub_label: t.business_sub_label,
created_at: common_utils::date_time::now(),
modified_at: common_utils::date_time::now(),
};
accounts.push(account.clone());
Ok(account)

View File

@ -31,6 +31,7 @@ pub struct Customer {
pub description: Option<String>,
pub created_at: PrimitiveDateTime,
pub metadata: Option<pii::SecretSerdeValue>,
pub modified_at: PrimitiveDateTime,
}
#[derive(Debug)]
@ -54,6 +55,7 @@ pub struct CustomerUpdateInternal {
description: Option<String>,
phone_country_code: Option<String>,
metadata: Option<pii::SecretSerdeValue>,
modified_at: Option<PrimitiveDateTime>,
}
impl From<CustomerUpdate> for CustomerUpdateInternal {
@ -73,6 +75,7 @@ impl From<CustomerUpdate> for CustomerUpdateInternal {
description,
phone_country_code,
metadata,
modified_at: Some(common_utils::date_time::now()),
},
}
}

View File

@ -35,6 +35,8 @@ pub struct MerchantAccount {
pub routing_algorithm: Option<serde_json::Value>,
pub primary_business_details: serde_json::Value,
pub api_key: Option<StrongSecret<String>>,
pub created_at: time::PrimitiveDateTime,
pub modified_at: time::PrimitiveDateTime,
}
#[derive(Clone, Debug, Default, Insertable, router_derive::DebugAsDisplay)]
@ -99,6 +101,7 @@ pub struct MerchantAccountUpdateInternal {
metadata: Option<pii::SecretSerdeValue>,
routing_algorithm: Option<serde_json::Value>,
primary_business_details: Option<serde_json::Value>,
modified_at: Option<time::PrimitiveDateTime>,
}
impl From<MerchantAccountUpdate> for MerchantAccountUpdateInternal {
@ -134,6 +137,7 @@ impl From<MerchantAccountUpdate> for MerchantAccountUpdateInternal {
locker_id,
metadata,
primary_business_details,
modified_at: Some(common_utils::date_time::now()),
..Default::default()
},
MerchantAccountUpdate::StorageSchemeUpdate { storage_scheme } => Self {

View File

@ -33,6 +33,8 @@ pub struct MerchantConnectorAccount {
pub business_country: storage_enums::CountryCode,
pub business_label: String,
pub business_sub_label: Option<String>,
pub created_at: time::PrimitiveDateTime,
pub modified_at: time::PrimitiveDateTime,
}
#[derive(Clone, Debug, Default, Insertable, router_derive::DebugAsDisplay)]
@ -80,6 +82,7 @@ pub struct MerchantConnectorAccountUpdateInternal {
payment_methods_enabled: Option<Vec<serde_json::Value>>,
metadata: Option<pii::SecretSerdeValue>,
frm_configs: Option<Secret<serde_json::Value>>,
modified_at: Option<time::PrimitiveDateTime>,
}
impl From<MerchantConnectorAccountUpdate> for MerchantConnectorAccountUpdateInternal {
@ -105,6 +108,7 @@ impl From<MerchantConnectorAccountUpdate> for MerchantConnectorAccountUpdateInte
payment_methods_enabled,
metadata,
frm_configs,
modified_at: Some(common_utils::date_time::now()),
},
}
}

View File

@ -106,6 +106,7 @@ diesel::table! {
description -> Nullable<Varchar>,
created_at -> Timestamp,
metadata -> Nullable<Json>,
modified_at -> Timestamp,
}
}
@ -228,6 +229,8 @@ diesel::table! {
routing_algorithm -> Nullable<Json>,
primary_business_details -> Json,
api_key -> Nullable<Varchar>,
created_at -> Timestamp,
modified_at -> Timestamp,
}
}
@ -251,6 +254,8 @@ diesel::table! {
business_country -> CountryCode,
business_label -> Varchar,
business_sub_label -> Nullable<Varchar>,
created_at -> Timestamp,
modified_at -> Timestamp,
}
}

View File

@ -0,0 +1,12 @@
-- This file should undo anything in `up.sql`
ALTER TABLE merchant_account
DROP COLUMN IF EXISTS created_at,
DROP COLUMN IF EXISTS modified_at;
ALTER TABLE merchant_connector_account
DROP COLUMN IF EXISTS created_at,
DROP COLUMN IF EXISTS modified_at;
ALTER TABLE customers
DROP COLUMN IF EXISTS modified_at;

View File

@ -0,0 +1,12 @@
-- Your SQL goes here
ALTER TABLE merchant_account
ADD COLUMN IF NOT EXISTS created_at TIMESTAMP NOT NULL DEFAULT now(),
ADD COLUMN IF NOT EXISTS modified_at TIMESTAMP NOT NULL DEFAULT now();
ALTER TABLE merchant_connector_account
ADD COLUMN IF NOT EXISTS created_at TIMESTAMP NOT NULL DEFAULT now(),
ADD COLUMN IF NOT EXISTS modified_at TIMESTAMP NOT NULL DEFAULT now();
ALTER TABLE customers
ADD COLUMN IF NOT EXISTS modified_at TIMESTAMP NOT NULL DEFAULT now();