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

refactor(core): change primary key of refund table #5367

Merged
merged 2 commits into from
Jul 19, 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
2 changes: 1 addition & 1 deletion crates/diesel_models/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,7 @@ diesel::table! {
use diesel::sql_types::*;
use crate::enums::diesel_exports::*;

refund (id) {
refund (merchant_id, refund_id) {
id -> Int4,
#[max_length = 64]
internal_reference_id -> Varchar,
Expand Down
2 changes: 1 addition & 1 deletion crates/diesel_models/src/schema_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,7 @@ diesel::table! {
use diesel::sql_types::*;
use crate::enums::diesel_exports::*;

refund (id) {
refund (merchant_id, refund_id) {
id -> Int4,
#[max_length = 64]
internal_reference_id -> Varchar,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- This file should undo anything in `up.sql`
ALTER TABLE refund DROP CONSTRAINT refund_pkey;

ALTER TABLE refund
ADD PRIMARY KEY (id);
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-- Your SQL goes here
-- The below query will lock the refund table
-- Running this query is not necessary on higher environments
-- as the application will work fine without these queries being run
-- This query should be run after the new version of application is deployed
ALTER TABLE refund DROP CONSTRAINT refund_pkey;

-- Use the `merchant_id, refund_id` columns as primary key
-- These are already unique, not null columns
-- So this query should not fail for not null or duplicate value reasons
ALTER TABLE refund
ADD PRIMARY KEY (merchant_id, refund_id);
Loading