mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 04:04:43 +08:00
chore(dispute): adding disputeamount as int type (#3886)
This commit is contained in:
committed by
GitHub
parent
de7f400c07
commit
7db499d8a9
@ -29,6 +29,7 @@ pub struct DisputeNew {
|
|||||||
pub evidence: Option<Secret<serde_json::Value>>,
|
pub evidence: Option<Secret<serde_json::Value>>,
|
||||||
pub profile_id: Option<String>,
|
pub profile_id: Option<String>,
|
||||||
pub merchant_connector_id: Option<String>,
|
pub merchant_connector_id: Option<String>,
|
||||||
|
pub dispute_amount: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Serialize, Identifiable, Queryable)]
|
#[derive(Clone, Debug, PartialEq, Serialize, Identifiable, Queryable)]
|
||||||
@ -59,6 +60,7 @@ pub struct Dispute {
|
|||||||
pub evidence: Secret<serde_json::Value>,
|
pub evidence: Secret<serde_json::Value>,
|
||||||
pub profile_id: Option<String>,
|
pub profile_id: Option<String>,
|
||||||
pub merchant_connector_id: Option<String>,
|
pub merchant_connector_id: Option<String>,
|
||||||
|
pub dispute_amount: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|||||||
@ -295,6 +295,7 @@ diesel::table! {
|
|||||||
profile_id -> Nullable<Varchar>,
|
profile_id -> Nullable<Varchar>,
|
||||||
#[max_length = 32]
|
#[max_length = 32]
|
||||||
merchant_connector_id -> Nullable<Varchar>,
|
merchant_connector_id -> Nullable<Varchar>,
|
||||||
|
dispute_amount -> Int8,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -352,7 +352,7 @@ pub async fn get_or_update_dispute_object(
|
|||||||
let dispute_id = generate_id(consts::ID_LENGTH, "dp");
|
let dispute_id = generate_id(consts::ID_LENGTH, "dp");
|
||||||
let new_dispute = diesel_models::dispute::DisputeNew {
|
let new_dispute = diesel_models::dispute::DisputeNew {
|
||||||
dispute_id,
|
dispute_id,
|
||||||
amount: dispute_details.amount,
|
amount: dispute_details.amount.clone(),
|
||||||
currency: dispute_details.currency,
|
currency: dispute_details.currency,
|
||||||
dispute_stage: dispute_details.dispute_stage,
|
dispute_stage: dispute_details.dispute_stage,
|
||||||
dispute_status: event_type
|
dispute_status: event_type
|
||||||
@ -374,6 +374,7 @@ pub async fn get_or_update_dispute_object(
|
|||||||
profile_id: Some(business_profile.profile_id.clone()),
|
profile_id: Some(business_profile.profile_id.clone()),
|
||||||
evidence: None,
|
evidence: None,
|
||||||
merchant_connector_id: payment_attempt.merchant_connector_id.clone(),
|
merchant_connector_id: payment_attempt.merchant_connector_id.clone(),
|
||||||
|
dispute_amount: dispute_details.amount.parse::<i64>().unwrap_or(0),
|
||||||
};
|
};
|
||||||
state
|
state
|
||||||
.store
|
.store
|
||||||
|
|||||||
@ -180,6 +180,7 @@ impl DisputeInterface for MockDb {
|
|||||||
profile_id: dispute.profile_id,
|
profile_id: dispute.profile_id,
|
||||||
evidence,
|
evidence,
|
||||||
merchant_connector_id: dispute.merchant_connector_id,
|
merchant_connector_id: dispute.merchant_connector_id,
|
||||||
|
dispute_amount: dispute.dispute_amount,
|
||||||
};
|
};
|
||||||
|
|
||||||
locked_disputes.push(new_dispute.clone());
|
locked_disputes.push(new_dispute.clone());
|
||||||
@ -414,6 +415,7 @@ mod tests {
|
|||||||
evidence: Some(Secret::from(Value::String("evidence".into()))),
|
evidence: Some(Secret::from(Value::String("evidence".into()))),
|
||||||
profile_id: None,
|
profile_id: None,
|
||||||
merchant_connector_id: None,
|
merchant_connector_id: None,
|
||||||
|
dispute_amount: 1040,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,17 @@
|
|||||||
|
-- This file should undo anything in `up.sql`
|
||||||
|
-- Drop the new column
|
||||||
|
ALTER TABLE dispute
|
||||||
|
DROP COLUMN IF EXISTS dispute_amount;
|
||||||
|
|
||||||
|
-- Optionally, if you want to revert the UPDATE statement as well (assuming you have a backup)
|
||||||
|
-- You can restore the original data from the backup or use the old values to update the table
|
||||||
|
|
||||||
|
-- For example, if you have a backup and want to revert the changes made by the UPDATE statement
|
||||||
|
-- You can replace the data with the backup data or the original values
|
||||||
|
-- For demonstration purposes, we're assuming you have a backup table named dispute_backup
|
||||||
|
|
||||||
|
-- Restore the original values from the backup or any other source
|
||||||
|
-- UPDATE dispute
|
||||||
|
-- SET dispute_amount = backup.dispute_amount
|
||||||
|
-- FROM dispute_backup AS backup
|
||||||
|
-- WHERE dispute.id = backup.id;
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
-- Your SQL goes here
|
||||||
|
-- Add the new column with a default value
|
||||||
|
ALTER TABLE dispute
|
||||||
|
ADD COLUMN dispute_amount BIGINT NOT NULL DEFAULT 0;
|
||||||
|
|
||||||
|
-- Update existing rows to set the default value based on the integer equivalent of the amount column
|
||||||
|
UPDATE dispute
|
||||||
|
SET dispute_amount = CAST(amount AS BIGINT);
|
||||||
Reference in New Issue
Block a user