feat: Remove fields from payment models that were leftovers from v1 (#10987)

This commit is contained in:
Stevche Radevski
2025-01-16 10:10:03 +01:00
committed by GitHub
parent 8cd58b3092
commit da8e173974
16 changed files with 37 additions and 287 deletions

View File

@@ -60,15 +60,6 @@
"nullable": true,
"mappedType": "decimal"
},
"region_id": {
"name": "region_id",
"type": "text",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"mappedType": "text"
},
"completed_at": {
"name": "completed_at",
"type": "timestamptz",
@@ -185,14 +176,6 @@
"unique": false,
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_payment_collection_deleted_at\" ON \"payment_collection\" (deleted_at) WHERE deleted_at IS NULL"
},
{
"keyName": "IDX_payment_collection_region_id",
"columnNames": [],
"composite": false,
"primary": false,
"unique": false,
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_payment_collection_region_id\" ON \"payment_collection\" (region_id) WHERE deleted_at IS NULL"
},
{
"keyName": "payment_collection_pkey",
"columnNames": [
@@ -700,33 +683,6 @@
"nullable": false,
"mappedType": "text"
},
"cart_id": {
"name": "cart_id",
"type": "text",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": true,
"mappedType": "text"
},
"order_id": {
"name": "order_id",
"type": "text",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": true,
"mappedType": "text"
},
"customer_id": {
"name": "customer_id",
"type": "text",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": true,
"mappedType": "text"
},
"data": {
"name": "data",
"type": "jsonb",

View File

@@ -0,0 +1,21 @@
import { Migration } from '@mikro-orm/migrations';
export class Migration20250115160517 extends Migration {
async up(): Promise<void> {
this.addSql('drop index if exists "IDX_payment_collection_region_id";');
this.addSql('alter table if exists "payment_collection" drop column if exists "region_id";');
this.addSql('alter table if exists "payment" drop column if exists "cart_id";');
this.addSql('alter table if exists "payment" drop column if exists "order_id";');
this.addSql('alter table if exists "payment" drop column if exists "customer_id";');
}
async down(): Promise<void> {
this.addSql('alter table if exists "payment_collection" add column if not exists "region_id" text not null;');
this.addSql('CREATE INDEX IF NOT EXISTS "IDX_payment_collection_region_id" ON "payment_collection" (region_id) WHERE deleted_at IS NULL;');
this.addSql('alter table if exists "payment" add column if not exists "cart_id" text null, add column if not exists "order_id" text null, add column if not exists "customer_id" text null;');
}
}

View File

@@ -11,7 +11,6 @@ const PaymentCollection = model
authorized_amount: model.bigNumber().nullable(),
captured_amount: model.bigNumber().nullable(),
refunded_amount: model.bigNumber().nullable(),
region_id: model.text(),
completed_at: model.dateTime().nullable(),
status: model
.enum(PaymentCollectionStatus)
@@ -30,11 +29,5 @@ const PaymentCollection = model
.cascades({
delete: ["payment_sessions", "payments"],
})
.indexes([
{
name: "IDX_payment_collection_region_id",
on: ["region_id"],
},
])
export default PaymentCollection

View File

@@ -10,9 +10,6 @@ const Payment = model
amount: model.bigNumber(),
currency_code: model.text(),
provider_id: model.text(),
cart_id: model.text().searchable().nullable(),
order_id: model.text().searchable().nullable(),
customer_id: model.text().searchable().nullable(),
data: model.json().nullable(),
metadata: model.json().nullable(),
captured_at: model.dateTime().nullable(),