diff --git a/.changeset/two-olives-try.md b/.changeset/two-olives-try.md new file mode 100644 index 0000000000..5f59a15b12 --- /dev/null +++ b/.changeset/two-olives-try.md @@ -0,0 +1,15 @@ +--- +"@medusajs/cart": patch +"@medusajs/fulfillment": patch +"@medusajs/notification": patch +"@medusajs/order": patch +"@medusajs/payment": patch +"@medusajs/pricing": patch +"@medusajs/product": patch +"@medusajs/promotion": patch +"@medusajs/store": patch +"@medusajs/translation": patch +"@medusajs/utils": patch +--- + +chore(): Migration generator fix generated import diff --git a/packages/core/utils/src/dal/mikro-orm/mikro-orm-create-connection.ts b/packages/core/utils/src/dal/mikro-orm/mikro-orm-create-connection.ts index c5defbe026..1e3514cef9 100644 --- a/packages/core/utils/src/dal/mikro-orm/mikro-orm-create-connection.ts +++ b/packages/core/utils/src/dal/mikro-orm/mikro-orm-create-connection.ts @@ -7,6 +7,9 @@ import { CustomDBMigrator } from "./custom-db-migrator" type FilterDef = Parameters[0] +const expectedMigrationsImportStatement = + 'import { Migration } from "@medusajs/framework/mikro-orm/migrations"' + export class CustomTsMigrationGenerator extends TSMigrationGenerator { // TODO: temporary fix to drop unique constraint before creating unique index private dropUniqueConstraintBeforeUniqueIndex( @@ -41,7 +44,17 @@ export class CustomTsMigrationGenerator extends TSMigrationGenerator { diff.up.unshift(sql) } - return super.generateMigrationFile(className, diff) + let migrationFileContent = super.generateMigrationFile(className, diff) + migrationFileContent = migrationFileContent + .replace( + 'import { Migration } from "@mikro-orm/migrations"', + expectedMigrationsImportStatement + ) + .replace( + "import { Migration } from '@mikro-orm/migrations'", + expectedMigrationsImportStatement + ) + return migrationFileContent } createStatement(sql: string, padLeft: number): string { diff --git a/packages/modules/cart/src/migrations/Migration20251208130704.ts b/packages/modules/cart/src/migrations/Migration20251208130704.ts index 0739f95177..b224491de8 100644 --- a/packages/modules/cart/src/migrations/Migration20251208130704.ts +++ b/packages/modules/cart/src/migrations/Migration20251208130704.ts @@ -1,4 +1,4 @@ -import { Migration } from "@mikro-orm/migrations" +import { Migration } from "@medusajs/framework/mikro-orm/migrations" export class Migration20251208130704 extends Migration { override async up(): Promise { diff --git a/packages/modules/fulfillment/src/migrations/Migration20251114133146.ts b/packages/modules/fulfillment/src/migrations/Migration20251114133146.ts index 0fa7fe5767..17ff377346 100644 --- a/packages/modules/fulfillment/src/migrations/Migration20251114133146.ts +++ b/packages/modules/fulfillment/src/migrations/Migration20251114133146.ts @@ -1,13 +1,15 @@ -import { Migration } from '@mikro-orm/migrations'; +import { Migration } from "@medusajs/framework/mikro-orm/migrations" export class Migration20251114133146 extends Migration { - override async up(): Promise { - this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_shipping_option_shipping_option_type_id" ON "shipping_option" ("shipping_option_type_id") WHERE deleted_at IS NULL;`); + this.addSql( + `CREATE INDEX IF NOT EXISTS "IDX_shipping_option_shipping_option_type_id" ON "shipping_option" ("shipping_option_type_id") WHERE deleted_at IS NULL;` + ) } override async down(): Promise { - this.addSql(`drop index if exists "IDX_shipping_option_shipping_option_type_id";`); + this.addSql( + `drop index if exists "IDX_shipping_option_shipping_option_type_id";` + ) } - } diff --git a/packages/modules/notification/src/migrations/Migration20251121123942.ts b/packages/modules/notification/src/migrations/Migration20251121123942.ts index c8c1102850..7b8ce9a000 100644 --- a/packages/modules/notification/src/migrations/Migration20251121123942.ts +++ b/packages/modules/notification/src/migrations/Migration20251121123942.ts @@ -1,13 +1,15 @@ -import { Migration } from '@mikro-orm/migrations'; +import { Migration } from "@medusajs/framework/mikro-orm/migrations" export class Migration20251121123942 extends Migration { - override async up(): Promise { - this.addSql(`alter table if exists "notification" add column if not exists "from" text null;`); + this.addSql( + `alter table if exists "notification" add column if not exists "from" text null;` + ) } override async down(): Promise { - this.addSql(`alter table if exists "notification" drop column if exists "from";`); + this.addSql( + `alter table if exists "notification" drop column if exists "from";` + ) } - } diff --git a/packages/modules/notification/src/migrations/Migration20251121150408.ts b/packages/modules/notification/src/migrations/Migration20251121150408.ts index bf1855dc2e..d1c2e2b6b9 100644 --- a/packages/modules/notification/src/migrations/Migration20251121150408.ts +++ b/packages/modules/notification/src/migrations/Migration20251121150408.ts @@ -1,13 +1,15 @@ -import { Migration } from '@mikro-orm/migrations'; +import { Migration } from "@medusajs/framework/mikro-orm/migrations" export class Migration20251121150408 extends Migration { - override async up(): Promise { - this.addSql(`alter table if exists "notification" add column if not exists "provider_data" jsonb null;`); + this.addSql( + `alter table if exists "notification" add column if not exists "provider_data" jsonb null;` + ) } override async down(): Promise { - this.addSql(`alter table if exists "notification" drop column if exists "provider_data";`); + this.addSql( + `alter table if exists "notification" drop column if exists "provider_data";` + ) } - } diff --git a/packages/modules/order/src/migrations/Migration20250910130000.ts b/packages/modules/order/src/migrations/Migration20250910130000.ts index d44a8cf9e7..c1ef15b5ef 100644 --- a/packages/modules/order/src/migrations/Migration20250910130000.ts +++ b/packages/modules/order/src/migrations/Migration20250910130000.ts @@ -1,4 +1,4 @@ -import { Migration } from "@mikro-orm/migrations" +import { Migration } from "@medusajs/framework/mikro-orm/migrations" export class Migration20250910130000 extends Migration { override async up(): Promise { diff --git a/packages/modules/order/src/migrations/Migration20251016160403.ts b/packages/modules/order/src/migrations/Migration20251016160403.ts index 9afad5360f..2fe199e4f8 100644 --- a/packages/modules/order/src/migrations/Migration20251016160403.ts +++ b/packages/modules/order/src/migrations/Migration20251016160403.ts @@ -1,4 +1,4 @@ -import { Migration } from "@mikro-orm/migrations" +import { Migration } from "@medusajs/framework/mikro-orm/migrations" export class Migration20251016160403 extends Migration { override async up(): Promise { diff --git a/packages/modules/order/src/migrations/Migration20251125164002.ts b/packages/modules/order/src/migrations/Migration20251125164002.ts index 39360ba666..08e9cb62cd 100644 --- a/packages/modules/order/src/migrations/Migration20251125164002.ts +++ b/packages/modules/order/src/migrations/Migration20251125164002.ts @@ -1,4 +1,4 @@ -import { Migration } from "@mikro-orm/migrations" +import { Migration } from "@medusajs/framework/mikro-orm/migrations" export class Migration20251125164002 extends Migration { override async up(): Promise { diff --git a/packages/modules/order/src/migrations/Migration20251210112909.ts b/packages/modules/order/src/migrations/Migration20251210112909.ts index 9aafb2ae1c..75d01f3d3b 100644 --- a/packages/modules/order/src/migrations/Migration20251210112909.ts +++ b/packages/modules/order/src/migrations/Migration20251210112909.ts @@ -1,13 +1,13 @@ -import { Migration } from '@mikro-orm/migrations'; +import { Migration } from "@medusajs/framework/mikro-orm/migrations" export class Migration20251210112909 extends Migration { - override async up(): Promise { - this.addSql(`alter table if exists "order" add column if not exists "locale" text null;`); + this.addSql( + `alter table if exists "order" add column if not exists "locale" text null;` + ) } override async down(): Promise { - this.addSql(`alter table if exists "order" drop column if exists "locale";`); + this.addSql(`alter table if exists "order" drop column if exists "locale";`) } - } diff --git a/packages/modules/order/src/migrations/Migration20251210112924.ts b/packages/modules/order/src/migrations/Migration20251210112924.ts index 5f968dccdf..894735fe5d 100644 --- a/packages/modules/order/src/migrations/Migration20251210112924.ts +++ b/packages/modules/order/src/migrations/Migration20251210112924.ts @@ -1,4 +1,4 @@ -import { Migration } from "@mikro-orm/migrations" +import { Migration } from "@medusajs/framework/mikro-orm/migrations" export class Migration20251210112924 extends Migration { override async up(): Promise { diff --git a/packages/modules/payment/src/migrations/Migration20250924135437.ts b/packages/modules/payment/src/migrations/Migration20250924135437.ts index aecf1a2817..f01838d7bc 100644 --- a/packages/modules/payment/src/migrations/Migration20250924135437.ts +++ b/packages/modules/payment/src/migrations/Migration20250924135437.ts @@ -1,4 +1,4 @@ -import { Migration } from "@mikro-orm/migrations" +import { Migration } from "@medusajs/framework/mikro-orm/migrations" import { ulid } from "ulid" export class Migration20250924135437 extends Migration { diff --git a/packages/modules/payment/src/migrations/Migration20250929124701.ts b/packages/modules/payment/src/migrations/Migration20250929124701.ts index 114a01451e..d36fda1ab1 100644 --- a/packages/modules/payment/src/migrations/Migration20250929124701.ts +++ b/packages/modules/payment/src/migrations/Migration20250929124701.ts @@ -1,11 +1,9 @@ -import { Migration } from "@mikro-orm/migrations" +import { Migration } from "@medusajs/framework/mikro-orm/migrations" export class Migration20250929124701 extends Migration { override async up(): Promise { // Step 1: Add the column as nullable - this.addSql( - `alter table "refund_reason" add column "code" text;` - ) + this.addSql(`alter table "refund_reason" add column "code" text;`) // Step 2: Populate the code column from label (convert to snake_case) this.addSql(` diff --git a/packages/modules/pricing/src/migrations/Migration20251009110625.ts b/packages/modules/pricing/src/migrations/Migration20251009110625.ts index 800295a656..3d6180e678 100644 --- a/packages/modules/pricing/src/migrations/Migration20251009110625.ts +++ b/packages/modules/pricing/src/migrations/Migration20251009110625.ts @@ -1,4 +1,4 @@ -import { Migration } from "@mikro-orm/migrations" +import { Migration } from "@medusajs/framework/mikro-orm/migrations" export class Migration20251009110625 extends Migration { override async up(): Promise { diff --git a/packages/modules/product/src/migrations/Migration20250910154539.ts b/packages/modules/product/src/migrations/Migration20250910154539.ts index b5ce633545..acffdd566e 100644 --- a/packages/modules/product/src/migrations/Migration20250910154539.ts +++ b/packages/modules/product/src/migrations/Migration20250910154539.ts @@ -1,4 +1,4 @@ -import { Migration } from "@mikro-orm/migrations" +import { Migration } from "@medusajs/framework/mikro-orm/migrations" export class Migration20250910154539 extends Migration { override async up(): Promise { diff --git a/packages/modules/product/src/migrations/Migration20250929204438.ts b/packages/modules/product/src/migrations/Migration20250929204438.ts index b0e879d03e..9cc4d1a6be 100644 --- a/packages/modules/product/src/migrations/Migration20250929204438.ts +++ b/packages/modules/product/src/migrations/Migration20250929204438.ts @@ -1,4 +1,4 @@ -import { Migration } from "@mikro-orm/migrations" +import { Migration } from "@medusajs/framework/mikro-orm/migrations" export class Migration20250929204438 extends Migration { override async up(): Promise { diff --git a/packages/modules/product/src/migrations/Migration20251008132218.ts b/packages/modules/product/src/migrations/Migration20251008132218.ts index ccce1dad0b..551409e453 100644 --- a/packages/modules/product/src/migrations/Migration20251008132218.ts +++ b/packages/modules/product/src/migrations/Migration20251008132218.ts @@ -1,4 +1,4 @@ -import { Migration } from "@mikro-orm/migrations" +import { Migration } from "@medusajs/framework/mikro-orm/migrations" export class Migration20251008132218 extends Migration { override async up(): Promise { diff --git a/packages/modules/promotion/src/migrations/Migration20250909083125.ts b/packages/modules/promotion/src/migrations/Migration20250909083125.ts index c7ba4c6358..1024702151 100644 --- a/packages/modules/promotion/src/migrations/Migration20250909083125.ts +++ b/packages/modules/promotion/src/migrations/Migration20250909083125.ts @@ -1,4 +1,4 @@ -import { Migration } from "@mikro-orm/migrations" +import { Migration } from "@medusajs/framework/mikro-orm/migrations" export class Migration20250909083125 extends Migration { override async up(): Promise { diff --git a/packages/modules/promotion/src/migrations/Migration20250916120552.ts b/packages/modules/promotion/src/migrations/Migration20250916120552.ts index cfd1f87396..27113e8775 100644 --- a/packages/modules/promotion/src/migrations/Migration20250916120552.ts +++ b/packages/modules/promotion/src/migrations/Migration20250916120552.ts @@ -1,4 +1,4 @@ -import { Migration } from "@mikro-orm/migrations" +import { Migration } from "@medusajs/framework/mikro-orm/migrations" export class Migration20250916120552 extends Migration { override async up(): Promise { diff --git a/packages/modules/promotion/src/migrations/Migration20251015113934.ts b/packages/modules/promotion/src/migrations/Migration20251015113934.ts index 5949434e6c..3b34c0f39b 100644 --- a/packages/modules/promotion/src/migrations/Migration20251015113934.ts +++ b/packages/modules/promotion/src/migrations/Migration20251015113934.ts @@ -1,4 +1,4 @@ -import { Migration } from "@mikro-orm/migrations" +import { Migration } from "@medusajs/framework/mikro-orm/migrations" export class Migration20251015113934 extends Migration { override async up(): Promise { diff --git a/packages/modules/promotion/src/migrations/Migration20251107050148.ts b/packages/modules/promotion/src/migrations/Migration20251107050148.ts index c1d35f67b7..23e756274c 100644 --- a/packages/modules/promotion/src/migrations/Migration20251107050148.ts +++ b/packages/modules/promotion/src/migrations/Migration20251107050148.ts @@ -1,13 +1,15 @@ -import { Migration } from '@mikro-orm/migrations'; +import { Migration } from "@medusajs/framework/mikro-orm/migrations" export class Migration20251107050148 extends Migration { - override async up(): Promise { - this.addSql(`alter table if exists "promotion" add column if not exists "metadata" jsonb null;`); + this.addSql( + `alter table if exists "promotion" add column if not exists "metadata" jsonb null;` + ) } override async down(): Promise { - this.addSql(`alter table if exists "promotion" drop column if exists "metadata";`); + this.addSql( + `alter table if exists "promotion" drop column if exists "metadata";` + ) } - } diff --git a/packages/modules/store/src/migrations/Migration20251202184737.ts b/packages/modules/store/src/migrations/Migration20251202184737.ts index 8687cd502e..0235a381a4 100644 --- a/packages/modules/store/src/migrations/Migration20251202184737.ts +++ b/packages/modules/store/src/migrations/Migration20251202184737.ts @@ -1,17 +1,23 @@ -import { Migration } from '@mikro-orm/migrations'; +import { Migration } from "@medusajs/framework/mikro-orm/migrations" export class Migration20251202184737 extends Migration { - override async up(): Promise { - this.addSql(`create table if not exists "store_locale" ("id" text not null, "locale_code" text not null, "is_default" boolean not null default false, "store_id" text null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "store_locale_pkey" primary key ("id"));`); - this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_store_locale_store_id" ON "store_locale" ("store_id") WHERE deleted_at IS NULL;`); - this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_store_locale_deleted_at" ON "store_locale" ("deleted_at") WHERE deleted_at IS NULL;`); + this.addSql( + `create table if not exists "store_locale" ("id" text not null, "locale_code" text not null, "is_default" boolean not null default false, "store_id" text null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "store_locale_pkey" primary key ("id"));` + ) + this.addSql( + `CREATE INDEX IF NOT EXISTS "IDX_store_locale_store_id" ON "store_locale" ("store_id") WHERE deleted_at IS NULL;` + ) + this.addSql( + `CREATE INDEX IF NOT EXISTS "IDX_store_locale_deleted_at" ON "store_locale" ("deleted_at") WHERE deleted_at IS NULL;` + ) - this.addSql(`alter table if exists "store_locale" add constraint "store_locale_store_id_foreign" foreign key ("store_id") references "store" ("id") on update cascade on delete cascade;`); + this.addSql( + `alter table if exists "store_locale" add constraint "store_locale_store_id_foreign" foreign key ("store_id") references "store" ("id") on update cascade on delete cascade;` + ) } override async down(): Promise { - this.addSql(`drop table if exists "store_locale" cascade;`); + this.addSql(`drop table if exists "store_locale" cascade;`) } - } diff --git a/packages/modules/store/src/migrations/Migration20251212161429.ts b/packages/modules/store/src/migrations/Migration20251212161429.ts index 9405ebf0fa..6cf03cfe1d 100644 --- a/packages/modules/store/src/migrations/Migration20251212161429.ts +++ b/packages/modules/store/src/migrations/Migration20251212161429.ts @@ -1,13 +1,15 @@ -import { Migration } from '@mikro-orm/migrations'; +import { Migration } from "@medusajs/framework/mikro-orm/migrations" export class Migration20251212161429 extends Migration { - override async up(): Promise { - this.addSql(`alter table if exists "store_locale" drop column if exists "is_default";`); + this.addSql( + `alter table if exists "store_locale" drop column if exists "is_default";` + ) } override async down(): Promise { - this.addSql(`alter table if exists "store_locale" add column if not exists "is_default" boolean not null default false;`); + this.addSql( + `alter table if exists "store_locale" add column if not exists "is_default" boolean not null default false;` + ) } - } diff --git a/packages/modules/translation/src/migrations/Migration20251215083927.ts b/packages/modules/translation/src/migrations/Migration20251215083927.ts index b52f60fd24..44877ca99e 100644 --- a/packages/modules/translation/src/migrations/Migration20251215083927.ts +++ b/packages/modules/translation/src/migrations/Migration20251215083927.ts @@ -1,13 +1,15 @@ -import { Migration } from '@mikro-orm/migrations'; +import { Migration } from "@medusajs/framework/mikro-orm/migrations" export class Migration20251215083927 extends Migration { - override async up(): Promise { - this.addSql(`alter table if exists "translation" add column if not exists "translated_field_count" integer not null default 0;`); + this.addSql( + `alter table if exists "translation" add column if not exists "translated_field_count" integer not null default 0;` + ) } override async down(): Promise { - this.addSql(`alter table if exists "translation" drop column if exists "translated_field_count";`); + this.addSql( + `alter table if exists "translation" drop column if exists "translated_field_count";` + ) } - }