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(merchant_account): change primary key for merchant account #5327

Merged
Merged
Show file tree
Hide file tree
Changes from 9 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
25 changes: 21 additions & 4 deletions .github/workflows/migration-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,31 @@ jobs:
features: postgres
args: "--no-default-features"

- name: Verify `diesel migration run`
- uses: baptiste0928/cargo-install@v2.2.0
with:
crate: just
args: "--no-default-features"

- name: Verify `diesel migration run for v1`
shell: bash
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres
run: just migrate run --locked-schema --all

- name: Verify `diesel migration redo for v1`
shell: bash
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres
run: just migrate redo --locked-schema --all

- name: Verify `diesel migration run for v2`
shell: bash
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres
run: make migrate locked-schema=yes
run: just migrate_v2 run --locked-schema --all

- name: Verify `diesel migration redo`
- name: Verify `diesel migration redo for v2`
shell: bash
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres
run: make redo_migrate locked-schema=yes
run: just migrate_v2 redo --locked-schema --all
7 changes: 6 additions & 1 deletion .github/workflows/postman-collection-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,17 @@ jobs:
features: postgres
args: "--no-default-features"

- uses: baptiste0928/cargo-install@v2.2.0
with:
crate: just
args: "--no-default-features"

- name: Diesel migration run
if: ${{ ((github.event_name == 'pull_request') && (github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name)) || (github.event_name == 'merge_group')}}
shell: bash
env:
DATABASE_URL: postgres://db_user:db_pass@localhost:5432/hyperswitch_db
run: make migrate locked-schema=yes
run: just migrate run --locked-schema

- name: Install newman from fork
run: npm ci
Expand Down
1 change: 1 addition & 0 deletions crates/diesel_models/src/payment_attempt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::{
#[derive(Clone, Debug, Eq, PartialEq, Identifiable, Queryable, Serialize, Deserialize)]
#[diesel(table_name = payment_attempt, primary_key(attempt_id, merchant_id))]
pub struct PaymentAttempt {
pub id: Option<i32>,
pub payment_id: String,
pub merchant_id: String,
pub attempt_id: String,
Expand Down
1 change: 1 addition & 0 deletions crates/diesel_models/src/payment_intent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::{encryption::Encryption, enums as storage_enums, schema::payment_inte
#[derive(Clone, Debug, PartialEq, Identifiable, Queryable, Serialize, Deserialize)]
#[diesel(table_name = payment_intent, primary_key(payment_id, merchant_id))]
pub struct PaymentIntent {
pub id: Option<i32>,
pub payment_id: String,
pub merchant_id: String,
pub status: storage_enums::IntentStatus,
Expand Down
2 changes: 1 addition & 1 deletion crates/diesel_models/src/query/merchant_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl MerchantAccount {
) -> StorageResult<Self> {
match generics::generic_update_by_id::<<Self as HasTable>::Table, _, _, _>(
conn,
self.id,
self.merchant_id.clone(),
merchant_account,
)
.await
Expand Down
4 changes: 3 additions & 1 deletion crates/diesel_models/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ diesel::table! {
use diesel::sql_types::*;
use crate::enums::diesel_exports::*;

merchant_account (id) {
merchant_account (merchant_id) {
id -> Int4,
#[max_length = 64]
merchant_id -> Varchar,
Expand Down Expand Up @@ -739,6 +739,7 @@ diesel::table! {
use crate::enums::diesel_exports::*;

payment_attempt (attempt_id, merchant_id) {
id -> Nullable<Int4>,
#[max_length = 64]
payment_id -> Varchar,
#[max_length = 64]
Expand Down Expand Up @@ -828,6 +829,7 @@ diesel::table! {
use crate::enums::diesel_exports::*;

payment_intent (payment_id, merchant_id) {
id -> Nullable<Int4>,
#[max_length = 64]
payment_id -> Varchar,
#[max_length = 64]
Expand Down
Loading
Loading