Skip to content

Commit 1f151ba

Browse files
feat(date_time): add created_at and modified_at to merchant related tables (#925)
1 parent 22cee8c commit 1f151ba

File tree

9 files changed

+45
-0
lines changed

9 files changed

+45
-0
lines changed

crates/router/src/db/customers.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ impl CustomerInterface for MockDb {
184184
description: customer_data.description,
185185
created_at: common_utils::date_time::now(),
186186
metadata: customer_data.metadata,
187+
modified_at: common_utils::date_time::now(),
187188
};
188189
customers.push(customer.clone());
189190
Ok(customer)

crates/router/src/db/merchant_account.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ impl MerchantAccountInterface for MockDb {
199199
locker_id: merchant_account.locker_id,
200200
metadata: merchant_account.metadata,
201201
primary_business_details: merchant_account.primary_business_details,
202+
created_at: common_utils::date_time::now(),
203+
modified_at: common_utils::date_time::now(),
202204
};
203205
accounts.push(account.clone());
204206
Ok(account)

crates/router/src/db/merchant_connector_account.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,8 @@ impl MerchantConnectorAccountInterface for MockDb {
295295
business_country: t.business_country,
296296
business_label: t.business_label,
297297
business_sub_label: t.business_sub_label,
298+
created_at: common_utils::date_time::now(),
299+
modified_at: common_utils::date_time::now(),
298300
};
299301
accounts.push(account.clone());
300302
Ok(account)

crates/storage_models/src/customers.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ pub struct Customer {
3131
pub description: Option<String>,
3232
pub created_at: PrimitiveDateTime,
3333
pub metadata: Option<pii::SecretSerdeValue>,
34+
pub modified_at: PrimitiveDateTime,
3435
}
3536

3637
#[derive(Debug)]
@@ -54,6 +55,7 @@ pub struct CustomerUpdateInternal {
5455
description: Option<String>,
5556
phone_country_code: Option<String>,
5657
metadata: Option<pii::SecretSerdeValue>,
58+
modified_at: Option<PrimitiveDateTime>,
5759
}
5860

5961
impl From<CustomerUpdate> for CustomerUpdateInternal {
@@ -73,6 +75,7 @@ impl From<CustomerUpdate> for CustomerUpdateInternal {
7375
description,
7476
phone_country_code,
7577
metadata,
78+
modified_at: Some(common_utils::date_time::now()),
7679
},
7780
}
7881
}

crates/storage_models/src/merchant_account.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ pub struct MerchantAccount {
3535
pub routing_algorithm: Option<serde_json::Value>,
3636
pub primary_business_details: serde_json::Value,
3737
pub api_key: Option<StrongSecret<String>>,
38+
pub created_at: time::PrimitiveDateTime,
39+
pub modified_at: time::PrimitiveDateTime,
3840
}
3941

4042
#[derive(Clone, Debug, Default, Insertable, router_derive::DebugAsDisplay)]
@@ -99,6 +101,7 @@ pub struct MerchantAccountUpdateInternal {
99101
metadata: Option<pii::SecretSerdeValue>,
100102
routing_algorithm: Option<serde_json::Value>,
101103
primary_business_details: Option<serde_json::Value>,
104+
modified_at: Option<time::PrimitiveDateTime>,
102105
}
103106

104107
impl From<MerchantAccountUpdate> for MerchantAccountUpdateInternal {
@@ -134,6 +137,7 @@ impl From<MerchantAccountUpdate> for MerchantAccountUpdateInternal {
134137
locker_id,
135138
metadata,
136139
primary_business_details,
140+
modified_at: Some(common_utils::date_time::now()),
137141
..Default::default()
138142
},
139143
MerchantAccountUpdate::StorageSchemeUpdate { storage_scheme } => Self {

crates/storage_models/src/merchant_connector_account.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ pub struct MerchantConnectorAccount {
3333
pub business_country: storage_enums::CountryCode,
3434
pub business_label: String,
3535
pub business_sub_label: Option<String>,
36+
pub created_at: time::PrimitiveDateTime,
37+
pub modified_at: time::PrimitiveDateTime,
3638
}
3739

3840
#[derive(Clone, Debug, Default, Insertable, router_derive::DebugAsDisplay)]
@@ -80,6 +82,7 @@ pub struct MerchantConnectorAccountUpdateInternal {
8082
payment_methods_enabled: Option<Vec<serde_json::Value>>,
8183
metadata: Option<pii::SecretSerdeValue>,
8284
frm_configs: Option<Secret<serde_json::Value>>,
85+
modified_at: Option<time::PrimitiveDateTime>,
8386
}
8487

8588
impl From<MerchantConnectorAccountUpdate> for MerchantConnectorAccountUpdateInternal {
@@ -105,6 +108,7 @@ impl From<MerchantConnectorAccountUpdate> for MerchantConnectorAccountUpdateInte
105108
payment_methods_enabled,
106109
metadata,
107110
frm_configs,
111+
modified_at: Some(common_utils::date_time::now()),
108112
},
109113
}
110114
}

crates/storage_models/src/schema.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ diesel::table! {
106106
description -> Nullable<Varchar>,
107107
created_at -> Timestamp,
108108
metadata -> Nullable<Json>,
109+
modified_at -> Timestamp,
109110
}
110111
}
111112

@@ -228,6 +229,8 @@ diesel::table! {
228229
routing_algorithm -> Nullable<Json>,
229230
primary_business_details -> Json,
230231
api_key -> Nullable<Varchar>,
232+
created_at -> Timestamp,
233+
modified_at -> Timestamp,
231234
}
232235
}
233236

@@ -251,6 +254,8 @@ diesel::table! {
251254
business_country -> CountryCode,
252255
business_label -> Varchar,
253256
business_sub_label -> Nullable<Varchar>,
257+
created_at -> Timestamp,
258+
modified_at -> Timestamp,
254259
}
255260
}
256261

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-- This file should undo anything in `up.sql`
2+
ALTER TABLE merchant_account
3+
DROP COLUMN IF EXISTS created_at,
4+
DROP COLUMN IF EXISTS modified_at;
5+
6+
7+
ALTER TABLE merchant_connector_account
8+
DROP COLUMN IF EXISTS created_at,
9+
DROP COLUMN IF EXISTS modified_at;
10+
11+
ALTER TABLE customers
12+
DROP COLUMN IF EXISTS modified_at;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-- Your SQL goes here
2+
ALTER TABLE merchant_account
3+
ADD COLUMN IF NOT EXISTS created_at TIMESTAMP NOT NULL DEFAULT now(),
4+
ADD COLUMN IF NOT EXISTS modified_at TIMESTAMP NOT NULL DEFAULT now();
5+
6+
ALTER TABLE merchant_connector_account
7+
ADD COLUMN IF NOT EXISTS created_at TIMESTAMP NOT NULL DEFAULT now(),
8+
ADD COLUMN IF NOT EXISTS modified_at TIMESTAMP NOT NULL DEFAULT now();
9+
10+
11+
ALTER TABLE customers
12+
ADD COLUMN IF NOT EXISTS modified_at TIMESTAMP NOT NULL DEFAULT now();

0 commit comments

Comments
 (0)