diff --git a/crates/router/src/db/customers.rs b/crates/router/src/db/customers.rs index f9f7ea96d2..cbdd99e2fd 100644 --- a/crates/router/src/db/customers.rs +++ b/crates/router/src/db/customers.rs @@ -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) diff --git a/crates/router/src/db/merchant_account.rs b/crates/router/src/db/merchant_account.rs index f1543fa08c..65d190448e 100644 --- a/crates/router/src/db/merchant_account.rs +++ b/crates/router/src/db/merchant_account.rs @@ -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) diff --git a/crates/router/src/db/merchant_connector_account.rs b/crates/router/src/db/merchant_connector_account.rs index 63413efe5e..61a1a7f82d 100644 --- a/crates/router/src/db/merchant_connector_account.rs +++ b/crates/router/src/db/merchant_connector_account.rs @@ -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) diff --git a/crates/storage_models/src/customers.rs b/crates/storage_models/src/customers.rs index 6f5ce70b83..180ecf022e 100644 --- a/crates/storage_models/src/customers.rs +++ b/crates/storage_models/src/customers.rs @@ -31,6 +31,7 @@ pub struct Customer { pub description: Option, pub created_at: PrimitiveDateTime, pub metadata: Option, + pub modified_at: PrimitiveDateTime, } #[derive(Debug)] @@ -54,6 +55,7 @@ pub struct CustomerUpdateInternal { description: Option, phone_country_code: Option, metadata: Option, + modified_at: Option, } impl From for CustomerUpdateInternal { @@ -73,6 +75,7 @@ impl From for CustomerUpdateInternal { description, phone_country_code, metadata, + modified_at: Some(common_utils::date_time::now()), }, } } diff --git a/crates/storage_models/src/merchant_account.rs b/crates/storage_models/src/merchant_account.rs index f834531d54..09af4a3d01 100644 --- a/crates/storage_models/src/merchant_account.rs +++ b/crates/storage_models/src/merchant_account.rs @@ -35,6 +35,8 @@ pub struct MerchantAccount { pub routing_algorithm: Option, pub primary_business_details: serde_json::Value, pub api_key: Option>, + 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, routing_algorithm: Option, primary_business_details: Option, + modified_at: Option, } impl From for MerchantAccountUpdateInternal { @@ -134,6 +137,7 @@ impl From for MerchantAccountUpdateInternal { locker_id, metadata, primary_business_details, + modified_at: Some(common_utils::date_time::now()), ..Default::default() }, MerchantAccountUpdate::StorageSchemeUpdate { storage_scheme } => Self { diff --git a/crates/storage_models/src/merchant_connector_account.rs b/crates/storage_models/src/merchant_connector_account.rs index 0d5a93ac2e..4dbbd8864e 100644 --- a/crates/storage_models/src/merchant_connector_account.rs +++ b/crates/storage_models/src/merchant_connector_account.rs @@ -33,6 +33,8 @@ pub struct MerchantConnectorAccount { pub business_country: storage_enums::CountryCode, pub business_label: String, pub business_sub_label: Option, + 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>, metadata: Option, frm_configs: Option>, + modified_at: Option, } impl From for MerchantConnectorAccountUpdateInternal { @@ -105,6 +108,7 @@ impl From for MerchantConnectorAccountUpdateInte payment_methods_enabled, metadata, frm_configs, + modified_at: Some(common_utils::date_time::now()), }, } } diff --git a/crates/storage_models/src/schema.rs b/crates/storage_models/src/schema.rs index 603f2945d6..a1d9ec2fd0 100644 --- a/crates/storage_models/src/schema.rs +++ b/crates/storage_models/src/schema.rs @@ -106,6 +106,7 @@ diesel::table! { description -> Nullable, created_at -> Timestamp, metadata -> Nullable, + modified_at -> Timestamp, } } @@ -228,6 +229,8 @@ diesel::table! { routing_algorithm -> Nullable, primary_business_details -> Json, api_key -> Nullable, + created_at -> Timestamp, + modified_at -> Timestamp, } } @@ -251,6 +254,8 @@ diesel::table! { business_country -> CountryCode, business_label -> Varchar, business_sub_label -> Nullable, + created_at -> Timestamp, + modified_at -> Timestamp, } } diff --git a/migrations/2023-04-19-120735_add_time_for_tables/down.sql b/migrations/2023-04-19-120735_add_time_for_tables/down.sql new file mode 100644 index 0000000000..82499e8504 --- /dev/null +++ b/migrations/2023-04-19-120735_add_time_for_tables/down.sql @@ -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; diff --git a/migrations/2023-04-19-120735_add_time_for_tables/up.sql b/migrations/2023-04-19-120735_add_time_for_tables/up.sql new file mode 100644 index 0000000000..af8dfb2fcc --- /dev/null +++ b/migrations/2023-04-19-120735_add_time_for_tables/up.sql @@ -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();