chore(): Migration generator fix generated import (#14315)
* chore(): Migration generator fix generated import * Create two-olives-try.md * feedback
This commit is contained in:
committed by
GitHub
parent
c8a7122ba9
commit
d813fc4ff9
15
.changeset/two-olives-try.md
Normal file
15
.changeset/two-olives-try.md
Normal file
@@ -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
|
||||
@@ -7,6 +7,9 @@ import { CustomDBMigrator } from "./custom-db-migrator"
|
||||
|
||||
type FilterDef = Parameters<typeof MikroORMFilter>[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 {
|
||||
|
||||
@@ -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<void> {
|
||||
|
||||
@@ -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<void> {
|
||||
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<void> {
|
||||
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";`
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<void> {
|
||||
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<void> {
|
||||
this.addSql(`alter table if exists "notification" drop column if exists "from";`);
|
||||
this.addSql(
|
||||
`alter table if exists "notification" drop column if exists "from";`
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<void> {
|
||||
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<void> {
|
||||
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";`
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<void> {
|
||||
|
||||
@@ -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<void> {
|
||||
|
||||
@@ -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<void> {
|
||||
|
||||
@@ -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<void> {
|
||||
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<void> {
|
||||
this.addSql(`alter table if exists "order" drop column if exists "locale";`);
|
||||
this.addSql(`alter table if exists "order" drop column if exists "locale";`)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<void> {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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<void> {
|
||||
// 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(`
|
||||
|
||||
@@ -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<void> {
|
||||
|
||||
@@ -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<void> {
|
||||
|
||||
@@ -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<void> {
|
||||
|
||||
@@ -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<void> {
|
||||
|
||||
@@ -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<void> {
|
||||
|
||||
@@ -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<void> {
|
||||
|
||||
@@ -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<void> {
|
||||
|
||||
@@ -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<void> {
|
||||
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<void> {
|
||||
this.addSql(`alter table if exists "promotion" drop column if exists "metadata";`);
|
||||
this.addSql(
|
||||
`alter table if exists "promotion" drop column if exists "metadata";`
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<void> {
|
||||
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<void> {
|
||||
this.addSql(`drop table if exists "store_locale" cascade;`);
|
||||
this.addSql(`drop table if exists "store_locale" cascade;`)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<void> {
|
||||
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<void> {
|
||||
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;`
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<void> {
|
||||
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<void> {
|
||||
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";`
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user