From aabe1647936374e19656c59126a5e988adf68c46 Mon Sep 17 00:00:00 2001 From: fPolic Date: Mon, 15 Jan 2024 10:34:45 +0100 Subject: [PATCH] fix: partial feedback address --- .../migrations/.snapshot-medusa-payment.json | 864 ------------------ .../src/migrations/Migration20240112131027.ts | 84 -- packages/payment/src/models/capture.ts | 4 +- .../payment/src/models/payment-collection.ts | 11 +- .../src/models/payment-method-token.ts | 2 +- .../payment/src/models/payment-provider.ts | 2 +- .../payment/src/models/payment-session.ts | 10 +- packages/payment/src/models/payment.ts | 5 +- 8 files changed, 18 insertions(+), 964 deletions(-) delete mode 100644 packages/payment/src/migrations/.snapshot-medusa-payment.json delete mode 100644 packages/payment/src/migrations/Migration20240112131027.ts diff --git a/packages/payment/src/migrations/.snapshot-medusa-payment.json b/packages/payment/src/migrations/.snapshot-medusa-payment.json deleted file mode 100644 index 2522b71b85..0000000000 --- a/packages/payment/src/migrations/.snapshot-medusa-payment.json +++ /dev/null @@ -1,864 +0,0 @@ -{ - "namespaces": [ - "public" - ], - "name": "public", - "tables": [ - { - "columns": { - "id": { - "name": "id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "text" - }, - "currency_code": { - "name": "currency_code", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "amount": { - "name": "amount", - "type": "numeric", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "decimal" - }, - "authorized_amount": { - "name": "authorized_amount", - "type": "numeric", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "decimal" - }, - "refunded_amount": { - "name": "refunded_amount", - "type": "numeric", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "decimal" - }, - "region_id": { - "name": "region_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "default": "now()", - "mappedType": "datetime" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "default": "now()", - "mappedType": "datetime" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - }, - "completed_at": { - "name": "completed_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - }, - "status": { - "name": "status", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "'not_paid'", - "enumItems": [ - "not_paid", - "awaiting", - "authorized", - "partially_authorized", - "canceled" - ], - "mappedType": "enum" - } - }, - "name": "payment-collection", - "schema": "public", - "indexes": [ - { - "columnNames": [ - "deleted_at" - ], - "composite": false, - "keyName": "IDX_payment_collection_deleted_at", - "primary": false, - "unique": false - }, - { - "keyName": "payment-collection_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "text" - }, - "provider_id": { - "name": "provider_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "text" - }, - "data": { - "name": "data", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "json" - }, - "name": { - "name": "name", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "text" - }, - "type_detail": { - "name": "type_detail", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "description_detail": { - "name": "description_detail", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "metadata": { - "name": "metadata", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "json" - } - }, - "name": "payment-method-token", - "schema": "public", - "indexes": [ - { - "keyName": "payment-method-token_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "text" - }, - "is_enabled": { - "name": "is_enabled", - "type": "boolean", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "true", - "mappedType": "boolean" - } - }, - "name": "payment-provider", - "schema": "public", - "indexes": [ - { - "keyName": "payment-provider_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": {} - }, - { - "columns": { - "payment_collection_id": { - "name": "payment_collection_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "text" - }, - "payment_provider_id": { - "name": "payment_provider_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "text" - } - }, - "name": "payment-collection_payment_providers", - "schema": "public", - "indexes": [ - { - "keyName": "payment-collection_payment_providers_pkey", - "columnNames": [ - "payment_collection_id", - "payment_provider_id" - ], - "composite": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "payment-collection_payment_providers_payment_coll_6b015_foreign": { - "constraintName": "payment-collection_payment_providers_payment_coll_6b015_foreign", - "columnNames": [ - "payment_collection_id" - ], - "localTableName": "public.payment-collection_payment_providers", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.payment-collection", - "deleteRule": "cascade", - "updateRule": "cascade" - }, - "payment-collection_payment_providers_payment_provider_id_foreign": { - "constraintName": "payment-collection_payment_providers_payment_provider_id_foreign", - "columnNames": [ - "payment_provider_id" - ], - "localTableName": "public.payment-collection_payment_providers", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.payment-provider", - "deleteRule": "cascade", - "updateRule": "cascade" - } - } - }, - { - "columns": { - "id": { - "name": "id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "text" - }, - "currency_code": { - "name": "currency_code", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "amount": { - "name": "amount", - "type": "numeric", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "decimal" - }, - "provider_id": { - "name": "provider_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "text" - }, - "data": { - "name": "data", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "json" - }, - "status": { - "name": "status", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "enumItems": [ - "authorized", - "pending", - "requires_more", - "error", - "canceled" - ], - "mappedType": "enum" - }, - "is_selected": { - "name": "is_selected", - "type": "boolean", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "boolean" - }, - "authorised_at": { - "name": "authorised_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - }, - "payment_collection_id": { - "name": "payment_collection_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "text" - } - }, - "name": "payment-session", - "schema": "public", - "indexes": [ - { - "columnNames": [ - "payment_collection_id" - ], - "composite": false, - "keyName": "IDX_payment_session_payment_collection_id", - "primary": false, - "unique": false - }, - { - "keyName": "payment-session_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "payment-session_payment_collection_id_foreign": { - "constraintName": "payment-session_payment_collection_id_foreign", - "columnNames": [ - "payment_collection_id" - ], - "localTableName": "public.payment-session", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.payment-collection", - "updateRule": "cascade" - } - } - }, - { - "columns": { - "id": { - "name": "id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "text" - }, - "amount": { - "name": "amount", - "type": "numeric", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "decimal" - }, - "authorized_amount": { - "name": "authorized_amount", - "type": "numeric", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "decimal" - }, - "currency_code": { - "name": "currency_code", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "text" - }, - "provider_id": { - "name": "provider_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "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", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "json" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "default": "now()", - "mappedType": "datetime" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "default": "now()", - "mappedType": "datetime" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - }, - "captured_at": { - "name": "captured_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - }, - "canceled_at": { - "name": "canceled_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - }, - "payment_collection_id": { - "name": "payment_collection_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "text" - }, - "session_id": { - "name": "session_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "text" - } - }, - "name": "payment", - "schema": "public", - "indexes": [ - { - "columnNames": [ - "deleted_at" - ], - "composite": false, - "keyName": "IDX_payment_deleted_at", - "primary": false, - "unique": false - }, - { - "columnNames": [ - "payment_collection_id" - ], - "composite": false, - "keyName": "IDX_payment_payment_collection_id", - "primary": false, - "unique": false - }, - { - "columnNames": [ - "session_id" - ], - "composite": false, - "keyName": "payment_session_id_unique", - "primary": false, - "unique": true - }, - { - "keyName": "payment_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "payment_payment_collection_id_foreign": { - "constraintName": "payment_payment_collection_id_foreign", - "columnNames": [ - "payment_collection_id" - ], - "localTableName": "public.payment", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.payment-collection", - "updateRule": "cascade" - }, - "payment_session_id_foreign": { - "constraintName": "payment_session_id_foreign", - "columnNames": [ - "session_id" - ], - "localTableName": "public.payment", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.payment-session", - "updateRule": "cascade" - } - } - }, - { - "columns": { - "id": { - "name": "id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "text" - }, - "amount": { - "name": "amount", - "type": "numeric", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "decimal" - }, - "payment_id": { - "name": "payment_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "text" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "default": "now()", - "mappedType": "datetime" - }, - "created_by": { - "name": "created_by", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - } - }, - "name": "capture", - "schema": "public", - "indexes": [ - { - "columnNames": [ - "payment_id" - ], - "composite": false, - "keyName": "IDX_capture_payment_id", - "primary": false, - "unique": false - }, - { - "keyName": "capture_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "capture_payment_id_foreign": { - "constraintName": "capture_payment_id_foreign", - "columnNames": [ - "payment_id" - ], - "localTableName": "public.capture", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.payment", - "deleteRule": "cascade", - "updateRule": "cascade" - } - } - }, - { - "columns": { - "id": { - "name": "id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "text" - }, - "amount": { - "name": "amount", - "type": "numeric", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "decimal" - }, - "payment_id": { - "name": "payment_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "text" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "default": "now()", - "mappedType": "datetime" - }, - "created_by": { - "name": "created_by", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - } - }, - "name": "refund", - "schema": "public", - "indexes": [ - { - "columnNames": [ - "payment_id" - ], - "composite": false, - "keyName": "IDX_refund_payment_id", - "primary": false, - "unique": false - }, - { - "keyName": "refund_pkey", - "columnNames": [ - "id" - ], - "composite": false, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "refund_payment_id_foreign": { - "constraintName": "refund_payment_id_foreign", - "columnNames": [ - "payment_id" - ], - "localTableName": "public.refund", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.payment", - "deleteRule": "cascade", - "updateRule": "cascade" - } - } - } - ] -} diff --git a/packages/payment/src/migrations/Migration20240112131027.ts b/packages/payment/src/migrations/Migration20240112131027.ts deleted file mode 100644 index cc588e5207..0000000000 --- a/packages/payment/src/migrations/Migration20240112131027.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { Migration } from "@mikro-orm/migrations" - -export class Migration20240112131027 extends Migration { - async up(): Promise { - this.addSql( - 'create table if not exists "payment-collection" ("id" text not null, "currency_code" text null, "amount" numeric not null, "authorized_amount" numeric null, "refunded_amount" numeric null, "region_id" text null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, "completed_at" timestamptz null, "status" text check ("status" in (\'not_paid\', \'awaiting\', \'authorized\', \'partially_authorized\', \'canceled\')) not null default \'not_paid\', constraint "payment-collection_pkey" primary key ("id"));' - ) - this.addSql( - 'create index "IDX_payment_collection_deleted_at" on "payment-collection" ("deleted_at");' - ) - - this.addSql( - 'create table if not exists "payment-method-token" ("id" text not null, "provider_id" text not null, "data" jsonb null, "name" text not null, "type_detail" text null, "description_detail" text null, "metadata" jsonb null, constraint "payment-method-token_pkey" primary key ("id"));' - ) - - this.addSql( - 'create table if not exists "payment-provider" ("id" text not null, "is_enabled" boolean not null default true, constraint "payment-provider_pkey" primary key ("id"));' - ) - - this.addSql( - 'create table if not exists "payment-collection_payment_providers" ("payment_collection_id" text not null, "payment_provider_id" text not null, constraint "payment-collection_payment_providers_pkey" primary key ("payment_collection_id", "payment_provider_id"));' - ) - - this.addSql( - 'create table if not exists "payment-session" ("id" text not null, "currency_code" text null, "amount" numeric not null, "provider_id" text not null, "data" jsonb null, "status" text check ("status" in (\'authorized\', \'pending\', \'requires_more\', \'error\', \'canceled\')) not null, "is_selected" boolean null, "authorised_at" timestamptz null, "payment_collection_id" text not null, constraint "payment-session_pkey" primary key ("id"));' - ) - this.addSql( - 'create index "IDX_payment_session_payment_collection_id" on "payment-session" ("payment_collection_id");' - ) - - this.addSql( - 'create table if not exists "payment" ("id" text not null, "amount" numeric not null, "authorized_amount" numeric null, "currency_code" text not null, "provider_id" text not null, "cart_id" text null, "order_id" text null, "customer_id" text null, "data" jsonb null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, "captured_at" timestamptz null, "canceled_at" timestamptz null, "payment_collection_id" text not null, "session_id" text not null, constraint "payment_pkey" primary key ("id"));' - ) - this.addSql( - 'create index "IDX_payment_deleted_at" on "payment" ("deleted_at");' - ) - this.addSql( - 'create index "IDX_payment_payment_collection_id" on "payment" ("payment_collection_id");' - ) - this.addSql( - 'alter table "payment" add constraint "payment_session_id_unique" unique ("session_id");' - ) - - this.addSql( - 'create table if not exists "capture" ("id" text not null, "amount" numeric not null, "payment_id" text not null, "created_at" timestamptz not null default now(), "created_by" text null, constraint "capture_pkey" primary key ("id"));' - ) - this.addSql( - 'create index "IDX_capture_payment_id" on "capture" ("payment_id");' - ) - - this.addSql( - 'create table if not exists "refund" ("id" text not null, "amount" numeric not null, "payment_id" text not null, "created_at" timestamptz not null default now(), "created_by" text null, constraint "refund_pkey" primary key ("id"));' - ) - this.addSql( - 'create index "IDX_refund_payment_id" on "refund" ("payment_id");' - ) - - this.addSql( - 'alter table "payment-collection_payment_providers" add constraint "payment-collection_payment_providers_payment_coll_6b015_foreign" foreign key ("payment_collection_id") references "payment-collection" ("id") on update cascade on delete cascade;' - ) - this.addSql( - 'alter table "payment-collection_payment_providers" add constraint "payment-collection_payment_providers_payment_provider_id_foreign" foreign key ("payment_provider_id") references "payment-provider" ("id") on update cascade on delete cascade;' - ) - - this.addSql( - 'alter table "payment-session" add constraint "payment-session_payment_collection_id_foreign" foreign key ("payment_collection_id") references "payment-collection" ("id") on update cascade;' - ) - - this.addSql( - 'alter table "payment" add constraint "payment_payment_collection_id_foreign" foreign key ("payment_collection_id") references "payment-collection" ("id") on update cascade;' - ) - this.addSql( - 'alter table "payment" add constraint "payment_session_id_foreign" foreign key ("session_id") references "payment-session" ("id") on update cascade;' - ) - - this.addSql( - 'alter table "capture" add constraint "capture_payment_id_foreign" foreign key ("payment_id") references "payment" ("id") on update cascade on delete cascade;' - ) - - this.addSql( - 'alter table "refund" add constraint "refund_payment_id_foreign" foreign key ("payment_id") references "payment" ("id") on update cascade on delete cascade;' - ) - } -} diff --git a/packages/payment/src/models/capture.ts b/packages/payment/src/models/capture.ts index 8f6de9e116..9952342db1 100644 --- a/packages/payment/src/models/capture.ts +++ b/packages/payment/src/models/capture.ts @@ -45,11 +45,11 @@ export default class Capture { @BeforeCreate() onCreate() { - this.id = generateEntityId(this.id, "cap") + this.id = generateEntityId(this.id, "capt") } @OnInit() onInit() { - this.id = generateEntityId(this.id, "cap") + this.id = generateEntityId(this.id, "capt") } } diff --git a/packages/payment/src/models/payment-collection.ts b/packages/payment/src/models/payment-collection.ts index 2cf082418b..80f41c0151 100644 --- a/packages/payment/src/models/payment-collection.ts +++ b/packages/payment/src/models/payment-collection.ts @@ -1,5 +1,6 @@ import { BeforeCreate, + Cascade, Collection, Entity, Enum, @@ -54,7 +55,7 @@ type OptionalPaymentCollectionProps = | "completed_at" | DAL.SoftDeletableEntityDateColumns -@Entity({ tableName: "payment-collection" }) +@Entity({ tableName: "payment_collection" }) @Filter(DALUtils.mikroOrmSoftDeletableFilterOptions) export default class PaymentCollection { [OptionalProps]?: OptionalPaymentCollectionProps @@ -126,22 +127,22 @@ export default class PaymentCollection { payment_providers = new Collection(this) @OneToMany(() => PaymentSession, (ps) => ps.payment_collection, { - orphanRemoval: true, + cascade: [Cascade.REMOVE], }) payment_sessions = new Collection(this) @OneToMany(() => Payment, (payment) => payment.payment_collection, { - orphanRemoval: true, + cascade: [Cascade.REMOVE], }) payments = new Collection(this) @BeforeCreate() onCreate() { - this.id = generateEntityId(this.id, "paycol") + this.id = generateEntityId(this.id, "pay_col") } @OnInit() onInit() { - this.id = generateEntityId(this.id, "paycol") + this.id = generateEntityId(this.id, "pay_col") } } diff --git a/packages/payment/src/models/payment-method-token.ts b/packages/payment/src/models/payment-method-token.ts index 9756d93040..43dd4bbec5 100644 --- a/packages/payment/src/models/payment-method-token.ts +++ b/packages/payment/src/models/payment-method-token.ts @@ -15,7 +15,7 @@ type OptionalPaymentMethodTokenProps = | "description_detail" | "metadata" -@Entity({ tableName: "payment-method-token" }) +@Entity({ tableName: "payment_method_token" }) export default class PaymentMethodToken { [OptionalProps]?: OptionalPaymentMethodTokenProps diff --git a/packages/payment/src/models/payment-provider.ts b/packages/payment/src/models/payment-provider.ts index db5f53ae99..d5ff3c03f7 100644 --- a/packages/payment/src/models/payment-provider.ts +++ b/packages/payment/src/models/payment-provider.ts @@ -1,6 +1,6 @@ import { Entity, PrimaryKey, Property } from "@mikro-orm/core" -@Entity({ tableName: "payment-provider" }) +@Entity({ tableName: "payment_provider" }) export default class PaymentProvider { @PrimaryKey({ columnType: "text" }) id: string diff --git a/packages/payment/src/models/payment-session.ts b/packages/payment/src/models/payment-session.ts index e86c02dc91..c96d651722 100644 --- a/packages/payment/src/models/payment-session.ts +++ b/packages/payment/src/models/payment-session.ts @@ -47,10 +47,10 @@ type OptionalPaymentSessionProps = | "currency_code" | "data" | "is_selected" - | "authorised_at" + | "authorized_at" | DAL.EntityDateColumns -@Entity({ tableName: "payment-session" }) +@Entity({ tableName: "payment_session" }) export default class PaymentSession { [OptionalProps]?: OptionalPaymentSessionProps @@ -84,7 +84,7 @@ export default class PaymentSession { columnType: "timestamptz", nullable: true, }) - authorised_at: Date | null + authorized_at: Date | null @ManyToOne({ index: "IDX_payment_session_payment_collection_id", @@ -101,11 +101,11 @@ export default class PaymentSession { @BeforeCreate() onCreate() { - this.id = generateEntityId(this.id, "ps") + this.id = generateEntityId(this.id, "payses") } @OnInit() onInit() { - this.id = generateEntityId(this.id, "ps") + this.id = generateEntityId(this.id, "payses") } } diff --git a/packages/payment/src/models/payment.ts b/packages/payment/src/models/payment.ts index 05e3c64f22..15941df136 100644 --- a/packages/payment/src/models/payment.ts +++ b/packages/payment/src/models/payment.ts @@ -1,5 +1,6 @@ import { BeforeCreate, + Cascade, Collection, Entity, Filter, @@ -103,12 +104,12 @@ export default class Payment { canceled_at: Date | null @OneToMany(() => Refund, (refund) => refund.payment, { - orphanRemoval: true, + cascade: [Cascade.REMOVE], }) refunds = new Collection(this) @OneToMany(() => Capture, (capture) => capture.payment, { - orphanRemoval: true, + cascade: [Cascade.REMOVE], }) captures = new Collection(this)