Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(database): modified_at updated for every state change for Payment Attempts #5312

Merged
merged 20 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crates/diesel_models/src/address.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use common_utils::id_type;
use diesel::{AsChangeset, Identifiable, Insertable, Queryable};
use diesel::{AsChangeset, Identifiable, Insertable, Queryable, Selectable};
use serde::{Deserialize, Serialize};
use time::PrimitiveDateTime;

Expand Down Expand Up @@ -29,8 +29,8 @@ pub struct AddressNew {
pub email: Option<Encryption>,
}

#[derive(Clone, Debug, Queryable, Identifiable, Serialize, Deserialize)]
#[diesel(table_name = address, primary_key(address_id))]
#[derive(Clone, Debug, Queryable, Identifiable, Selectable, Serialize, Deserialize)]
#[diesel(table_name = address, primary_key(address_id), check_for_backend(diesel::pg::Pg))]
pub struct Address {
pub id: Option<i32>,
pub address_id: String,
Expand Down
8 changes: 5 additions & 3 deletions crates/diesel_models/src/api_keys.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use diesel::{AsChangeset, AsExpression, Identifiable, Insertable, Queryable};
use diesel::{AsChangeset, AsExpression, Identifiable, Insertable, Queryable, Selectable};
use serde::{Deserialize, Serialize};
use time::PrimitiveDateTime;

use crate::schema::api_keys;

#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, Identifiable, Queryable)]
#[diesel(table_name = api_keys, primary_key(key_id))]
#[derive(
serde::Serialize, serde::Deserialize, Debug, Clone, Identifiable, Queryable, Selectable,
)]
#[diesel(table_name = api_keys, primary_key(key_id), check_for_backend(diesel::pg::Pg))]
pub struct ApiKey {
pub key_id: String,
pub merchant_id: String,
Expand Down
8 changes: 5 additions & 3 deletions crates/diesel_models/src/authentication.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use diesel::{AsChangeset, Identifiable, Insertable, Queryable};
use diesel::{AsChangeset, Identifiable, Insertable, Queryable, Selectable};
use serde::{self, Deserialize, Serialize};
use serde_json;

use crate::schema::authentication;

#[derive(Clone, Debug, Eq, PartialEq, Identifiable, Queryable, Serialize, Deserialize)]
#[diesel(table_name = authentication, primary_key(authentication_id))]
#[derive(
Clone, Debug, Eq, PartialEq, Identifiable, Queryable, Selectable, Serialize, Deserialize,
)]
#[diesel(table_name = authentication, primary_key(authentication_id), check_for_backend(diesel::pg::Pg))]
pub struct Authentication {
pub authentication_id: String,
pub merchant_id: String,
Expand Down
9 changes: 5 additions & 4 deletions crates/diesel_models/src/authorization.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use common_utils::types::MinorUnit;
use diesel::{AsChangeset, Identifiable, Insertable, Queryable};
use diesel::{AsChangeset, Identifiable, Insertable, Queryable, Selectable};
use serde::{Deserialize, Serialize};
use time::PrimitiveDateTime;

use crate::{enums as storage_enums, schema::incremental_authorization};

#[derive(Clone, Debug, Eq, PartialEq, Identifiable, Queryable, Serialize, Deserialize, Hash)]
#[diesel(table_name = incremental_authorization)]
#[diesel(primary_key(authorization_id, merchant_id))]
#[derive(
Clone, Debug, Eq, PartialEq, Identifiable, Queryable, Selectable, Serialize, Deserialize, Hash,
)]
#[diesel(table_name = incremental_authorization, primary_key(authorization_id, merchant_id), check_for_backend(diesel::pg::Pg))]
pub struct Authorization {
pub authorization_id: String,
pub merchant_id: String,
Expand Down
8 changes: 5 additions & 3 deletions crates/diesel_models/src/blocklist.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use diesel::{Identifiable, Insertable, Queryable};
use diesel::{Identifiable, Insertable, Queryable, Selectable};
use serde::{Deserialize, Serialize};

use crate::schema::blocklist;
Expand All @@ -13,8 +13,10 @@ pub struct BlocklistNew {
pub created_at: time::PrimitiveDateTime,
}

#[derive(Clone, Debug, Eq, PartialEq, Identifiable, Queryable, Deserialize, Serialize)]
#[diesel(table_name = blocklist)]
#[derive(
Clone, Debug, Eq, PartialEq, Identifiable, Queryable, Selectable, Deserialize, Serialize,
)]
#[diesel(table_name = blocklist, check_for_backend(diesel::pg::Pg))]
pub struct Blocklist {
#[serde(skip)]
pub id: i32,
Expand Down
8 changes: 5 additions & 3 deletions crates/diesel_models/src/blocklist_fingerprint.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use diesel::{Identifiable, Insertable, Queryable};
use diesel::{Identifiable, Insertable, Queryable, Selectable};
use serde::{Deserialize, Serialize};

use crate::schema::blocklist_fingerprint;
Expand All @@ -13,8 +13,10 @@ pub struct BlocklistFingerprintNew {
pub created_at: time::PrimitiveDateTime,
}

#[derive(Clone, Debug, Eq, PartialEq, Queryable, Identifiable, Deserialize, Serialize)]
#[diesel(table_name = blocklist_fingerprint)]
#[derive(
Clone, Debug, Eq, PartialEq, Queryable, Identifiable, Selectable, Deserialize, Serialize,
)]
#[diesel(table_name = blocklist_fingerprint, check_for_backend(diesel::pg::Pg))]
pub struct BlocklistFingerprint {
#[serde(skip_serializing)]
pub id: i32,
Expand Down
17 changes: 14 additions & 3 deletions crates/diesel_models/src/blocklist_lookup.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use diesel::{Identifiable, Insertable, Queryable};
use diesel::{Identifiable, Insertable, Queryable, Selectable};
use serde::{Deserialize, Serialize};

use crate::schema::blocklist_lookup;
Expand All @@ -10,8 +10,19 @@ pub struct BlocklistLookupNew {
pub fingerprint: String,
}

#[derive(Default, Clone, Debug, Eq, PartialEq, Identifiable, Queryable, Deserialize, Serialize)]
#[diesel(table_name = blocklist_lookup)]
#[derive(
Default,
Clone,
Debug,
Eq,
PartialEq,
Identifiable,
Queryable,
Selectable,
Deserialize,
Serialize,
)]
#[diesel(table_name = blocklist_lookup, check_for_backend(diesel::pg::Pg))]
pub struct BlocklistLookup {
#[serde(skip)]
pub id: i32,
Expand Down
5 changes: 3 additions & 2 deletions crates/diesel_models/src/business_profile.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use common_utils::pii;
use diesel::{AsChangeset, Identifiable, Insertable, Queryable};
use diesel::{AsChangeset, Identifiable, Insertable, Queryable, Selectable};

use crate::schema::business_profile;

Expand All @@ -10,9 +10,10 @@ use crate::schema::business_profile;
serde::Serialize,
Identifiable,
Queryable,
Selectable,
router_derive::DebugAsDisplay,
)]
#[diesel(table_name = business_profile, primary_key(profile_id))]
#[diesel(table_name = business_profile, primary_key(profile_id), check_for_backend(diesel::pg::Pg))]
pub struct BusinessProfile {
pub profile_id: String,
pub merchant_id: String,
Expand Down
9 changes: 5 additions & 4 deletions crates/diesel_models/src/capture.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use common_utils::types::MinorUnit;
use diesel::{AsChangeset, Identifiable, Insertable, Queryable};
use diesel::{AsChangeset, Identifiable, Insertable, Queryable, Selectable};
use serde::{Deserialize, Serialize};
use time::PrimitiveDateTime;

use crate::{enums as storage_enums, schema::captures};

#[derive(Clone, Debug, Eq, PartialEq, Identifiable, Queryable, Serialize, Deserialize, Hash)]
#[diesel(table_name = captures)]
#[diesel(primary_key(capture_id))]
#[derive(
Clone, Debug, Eq, PartialEq, Identifiable, Queryable, Selectable, Serialize, Deserialize, Hash,
)]
#[diesel(table_name = captures, primary_key(capture_id), check_for_backend(diesel::pg::Pg))]
pub struct Capture {
pub capture_id: String,
pub payment_id: String,
Expand Down
8 changes: 5 additions & 3 deletions crates/diesel_models/src/cards_info.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use diesel::{Identifiable, Queryable};
use diesel::{Identifiable, Queryable, Selectable};
use time::PrimitiveDateTime;

use crate::{enums as storage_enums, schema::cards_info};

#[derive(Clone, Debug, Queryable, Identifiable, serde::Deserialize, serde::Serialize)]
#[diesel(table_name = cards_info, primary_key(card_iin))]
#[derive(
Clone, Debug, Queryable, Identifiable, Selectable, serde::Deserialize, serde::Serialize,
)]
#[diesel(table_name = cards_info, primary_key(card_iin), check_for_backend(diesel::pg::Pg))]
pub struct CardInfo {
pub card_iin: String,
pub card_issuer: Option<String>,
Expand Down
7 changes: 3 additions & 4 deletions crates/diesel_models/src/configs.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::convert::From;

use diesel::{AsChangeset, Identifiable, Insertable, Queryable};
use diesel::{AsChangeset, Identifiable, Insertable, Queryable, Selectable};
use serde::{Deserialize, Serialize};

use crate::schema::configs;
Expand All @@ -13,9 +13,8 @@ pub struct ConfigNew {
pub config: String,
}

#[derive(Default, Clone, Debug, Identifiable, Queryable, Deserialize, Serialize)]
#[diesel(table_name = configs)]

#[derive(Default, Clone, Debug, Identifiable, Queryable, Selectable, Deserialize, Serialize)]
#[diesel(table_name = configs, check_for_backend(diesel::pg::Pg))]
pub struct Config {
#[serde(skip)]
pub id: i32,
Expand Down
8 changes: 5 additions & 3 deletions crates/diesel_models/src/customers.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use common_utils::{id_type, pii};
use diesel::{AsChangeset, Identifiable, Insertable, Queryable};
use diesel::{AsChangeset, Identifiable, Insertable, Queryable, Selectable};
use time::PrimitiveDateTime;

use crate::{encryption::Encryption, schema::customers};
Expand Down Expand Up @@ -52,8 +52,10 @@ impl From<CustomerNew> for Customer {
}
}

#[derive(Clone, Debug, Identifiable, Queryable, serde::Deserialize, serde::Serialize)]
#[diesel(table_name = customers)]
#[derive(
Clone, Debug, Identifiable, Queryable, Selectable, serde::Deserialize, serde::Serialize,
)]
#[diesel(table_name = customers, check_for_backend(diesel::pg::Pg))]
pub struct Customer {
pub id: i32,
pub customer_id: id_type::CustomerId,
Expand Down
32 changes: 22 additions & 10 deletions crates/diesel_models/src/dispute.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use common_utils::custom_serde;
use diesel::{AsChangeset, Identifiable, Insertable, Queryable};
use diesel::{AsChangeset, Identifiable, Insertable, Queryable, Selectable};
use masking::Secret;
use serde::Serialize;
use time::PrimitiveDateTime;
Expand Down Expand Up @@ -32,8 +32,8 @@ pub struct DisputeNew {
pub dispute_amount: i64,
}

#[derive(Clone, Debug, PartialEq, Serialize, Identifiable, Queryable)]
#[diesel(table_name = dispute)]
#[derive(Clone, Debug, PartialEq, Serialize, Identifiable, Queryable, Selectable)]
#[diesel(table_name = dispute, check_for_backend(diesel::pg::Pg))]
pub struct Dispute {
#[serde(skip_serializing)]
pub id: i32,
Expand Down Expand Up @@ -83,7 +83,7 @@ pub enum DisputeUpdate {
},
}

#[derive(Clone, Debug, Default, AsChangeset, router_derive::DebugAsDisplay)]
#[derive(Clone, Debug, AsChangeset, router_derive::DebugAsDisplay)]
#[diesel(table_name = dispute)]
pub struct DisputeUpdateInternal {
dispute_stage: Option<storage_enums::DisputeStage>,
Expand All @@ -93,7 +93,7 @@ pub struct DisputeUpdateInternal {
connector_reason_code: Option<String>,
challenge_required_by: Option<PrimitiveDateTime>,
connector_updated_at: Option<PrimitiveDateTime>,
modified_at: Option<PrimitiveDateTime>,
modified_at: PrimitiveDateTime,
evidence: Option<Secret<serde_json::Value>>,
}

Expand All @@ -116,21 +116,33 @@ impl From<DisputeUpdate> for DisputeUpdateInternal {
connector_reason_code,
challenge_required_by,
connector_updated_at,
modified_at: Some(common_utils::date_time::now()),
..Default::default()
modified_at: common_utils::date_time::now(),
evidence: None,
},
DisputeUpdate::StatusUpdate {
dispute_status,
connector_status,
} => Self {
dispute_status: Some(dispute_status),
connector_status,
modified_at: Some(common_utils::date_time::now()),
..Default::default()
modified_at: common_utils::date_time::now(),
dispute_stage: None,
connector_reason: None,
connector_reason_code: None,
challenge_required_by: None,
connector_updated_at: None,
evidence: None,
},
DisputeUpdate::EvidenceUpdate { evidence } => Self {
evidence: Some(evidence),
..Default::default()
dispute_stage: None,
dispute_status: None,
connector_status: None,
connector_reason: None,
connector_reason_code: None,
challenge_required_by: None,
connector_updated_at: None,
modified_at: common_utils::date_time::now(),
},
}
}
Expand Down
9 changes: 4 additions & 5 deletions crates/diesel_models/src/events.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use common_utils::custom_serde;
use diesel::{
deserialize::FromSqlRow, expression::AsExpression, AsChangeset, Identifiable, Insertable,
Queryable,
expression::AsExpression, AsChangeset, Identifiable, Insertable, Queryable, Selectable,
};
use serde::{Deserialize, Serialize};
use time::PrimitiveDateTime;
Expand Down Expand Up @@ -36,8 +35,8 @@ pub struct EventUpdateInternal {
pub response: Option<Encryption>,
}

#[derive(Clone, Debug, Deserialize, Serialize, Identifiable, Queryable)]
#[diesel(table_name = events, primary_key(event_id))]
#[derive(Clone, Debug, Deserialize, Serialize, Identifiable, Queryable, Selectable)]
#[diesel(table_name = events, primary_key(event_id), check_for_backend(diesel::pg::Pg))]
pub struct Event {
pub event_id: String,
pub event_type: storage_enums::EventType,
Expand All @@ -60,7 +59,7 @@ pub struct Event {
pub metadata: Option<EventMetadata>,
}

#[derive(Clone, Debug, Deserialize, Serialize, AsExpression, FromSqlRow)]
#[derive(Clone, Debug, Deserialize, Serialize, AsExpression, diesel::FromSqlRow)]
#[diesel(sql_type = diesel::sql_types::Jsonb)]
pub enum EventMetadata {
Payment {
Expand Down
6 changes: 3 additions & 3 deletions crates/diesel_models/src/file.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use common_utils::custom_serde;
use diesel::{AsChangeset, Identifiable, Insertable, Queryable};
use diesel::{AsChangeset, Identifiable, Insertable, Queryable, Selectable};
use masking::{Deserialize, Serialize};

use crate::schema::file_metadata;
Expand All @@ -21,8 +21,8 @@ pub struct FileMetadataNew {
pub merchant_connector_id: Option<String>,
}

#[derive(Clone, Debug, Deserialize, Serialize, Identifiable, Queryable)]
#[diesel(table_name = file_metadata, primary_key(file_id, merchant_id))]
#[derive(Clone, Debug, Deserialize, Serialize, Identifiable, Queryable, Selectable)]
#[diesel(table_name = file_metadata, primary_key(file_id, merchant_id), check_for_backend(diesel::pg::Pg))]
pub struct FileMetadata {
#[serde(skip_serializing)]
pub file_id: String,
Expand Down
6 changes: 3 additions & 3 deletions crates/diesel_models/src/fraud_check.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use common_enums as storage_enums;
use diesel::{AsChangeset, Identifiable, Insertable, Queryable};
use diesel::{AsChangeset, Identifiable, Insertable, Queryable, Selectable};
use masking::{Deserialize, Serialize};
use time::PrimitiveDateTime;

use crate::{
enums::{FraudCheckLastStep, FraudCheckStatus, FraudCheckType},
schema::fraud_check,
};
#[derive(Clone, Debug, Identifiable, Queryable, Serialize, Deserialize)]
#[diesel(table_name = fraud_check, primary_key(payment_id, merchant_id))]
#[derive(Clone, Debug, Identifiable, Queryable, Selectable, Serialize, Deserialize)]
#[diesel(table_name = fraud_check, primary_key(payment_id, merchant_id), check_for_backend(diesel::pg::Pg))]
pub struct FraudCheck {
pub frm_id: String,
pub payment_id: String,
Expand Down
9 changes: 5 additions & 4 deletions crates/diesel_models/src/generic_link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ use common_utils::{
PayoutLinkData, PayoutLinkStatus,
},
};
use diesel::{AsChangeset, Identifiable, Insertable, Queryable};
use diesel::{AsChangeset, Identifiable, Insertable, Queryable, Selectable};
use masking::Secret;
use serde::{Deserialize, Serialize};
use time::{Duration, PrimitiveDateTime};

use crate::{enums as storage_enums, schema::generic_link};

#[derive(Clone, Debug, Eq, PartialEq, Identifiable, Queryable, Serialize, Deserialize)]
#[diesel(table_name = generic_link)]
#[diesel(primary_key(link_id))]
#[derive(
Clone, Debug, Eq, PartialEq, Identifiable, Queryable, Selectable, Serialize, Deserialize,
)]
#[diesel(table_name = generic_link, primary_key(link_id), check_for_backend(diesel::pg::Pg))]
pub struct GenericLink {
pub link_id: String,
pub primary_reference: String,
Expand Down
Loading
Loading