From d9640c2cc8bf94b174407f56c1bf9b21e297f16e Mon Sep 17 00:00:00 2001 From: Riqwan Thamir Date: Tue, 10 Oct 2023 13:30:51 +0200 Subject: [PATCH] chore: scope migrations to only to create if not exist - money amount, currency --- .../migrations/.snapshot-medusa-pricing.json | 28 ------------------- .../src/migrations/Migration20230929122253.ts | 2 +- .../src/migrations/Migration20231010102411.ts | 20 ------------- packages/pricing/src/models/money-amount.ts | 3 -- 4 files changed, 1 insertion(+), 52 deletions(-) delete mode 100644 packages/pricing/src/migrations/Migration20231010102411.ts diff --git a/packages/pricing/src/migrations/.snapshot-medusa-pricing.json b/packages/pricing/src/migrations/.snapshot-medusa-pricing.json index 696907d1b739e..1d5cad716c7cc 100644 --- a/packages/pricing/src/migrations/.snapshot-medusa-pricing.json +++ b/packages/pricing/src/migrations/.snapshot-medusa-pricing.json @@ -41,16 +41,6 @@ "primary": false, "nullable": false, "mappedType": "text" - }, - "includes_tax": { - "name": "includes_tax", - "type": "boolean", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "default": "false", - "mappedType": "boolean" } }, "name": "currency", @@ -115,24 +105,6 @@ "primary": false, "nullable": true, "mappedType": "decimal" - }, - "price_list_id": { - "name": "price_list_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" - }, - "region_id": { - "name": "region_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "mappedType": "text" } }, "name": "money_amount", diff --git a/packages/pricing/src/migrations/Migration20230929122253.ts b/packages/pricing/src/migrations/Migration20230929122253.ts index 67768c32f8c90..f4d0b843adb5e 100644 --- a/packages/pricing/src/migrations/Migration20230929122253.ts +++ b/packages/pricing/src/migrations/Migration20230929122253.ts @@ -10,7 +10,7 @@ export class Migration20230929122253 extends Migration { 'create table if not exists "money_amount" ("id" text not null, "currency_code" text null, "amount" numeric null, "min_quantity" numeric null, "max_quantity" numeric null, constraint "money_amount_pkey" primary key ("id"));' ) this.addSql( - 'create index "IDX_money_amount_currency_code" on "money_amount" ("currency_code");' + 'create index if not exists "IDX_money_amount_currency_code" on "money_amount" ("currency_code");' ) this.addSql( diff --git a/packages/pricing/src/migrations/Migration20231010102411.ts b/packages/pricing/src/migrations/Migration20231010102411.ts deleted file mode 100644 index f6686e8fd1b79..0000000000000 --- a/packages/pricing/src/migrations/Migration20231010102411.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Migration } from "@mikro-orm/migrations" - -export class Migration20231010102411 extends Migration { - async up(): Promise { - this.addSql( - 'alter table "currency" add column "includes_tax" boolean not null default false;' - ) - - this.addSql( - 'alter table "money_amount" add column "price_list_id" text null, add column "region_id" text null;' - ) - } - - async down(): Promise { - this.addSql('alter table "currency" drop column "includes_tax";') - - this.addSql('alter table "money_amount" drop column "price_list_id";') - this.addSql('alter table "money_amount" drop column "region_id";') - } -} diff --git a/packages/pricing/src/models/money-amount.ts b/packages/pricing/src/models/money-amount.ts index 9efc2a4a31d55..2f4b77758ee4b 100644 --- a/packages/pricing/src/models/money-amount.ts +++ b/packages/pricing/src/models/money-amount.ts @@ -42,9 +42,6 @@ class MoneyAmount { @Property({ columnType: "numeric", nullable: true }) max_quantity?: number | null - @Property({ columnType: "text", nullable: true }) - price_list_id?: string - @BeforeCreate() onCreate() { this.id = generateEntityId(this.id, "ma")