1 import { Migration } from "@medusajs/framework/mikro-orm/migrations"
2
3 export class Migration20250910154539 extends Migration {
4 override async up(): Promise<void> {
5 this.addSql(
6 `CREATE INDEX IF NOT EXISTS "IDX_image_product_id" ON "image" (product_id) WHERE deleted_at IS NULL;`
7 )
8 this.addSql(
9 `CREATE INDEX IF NOT EXISTS "IDX_image_deleted_at" ON "image" (deleted_at) WHERE deleted_at IS NULL;`
10 )
11 this.addSql(
12 `CREATE INDEX IF NOT EXISTS "IDX_product_image_url" ON "image" (url) WHERE deleted_at IS NULL;`
13 )
14 this.addSql(
15 `CREATE INDEX IF NOT EXISTS "IDX_product_image_rank" ON "image" (rank) WHERE deleted_at IS NULL;`
16 )
17 this.addSql(
18 `CREATE INDEX IF NOT EXISTS "IDX_product_image_url_rank_product_id" ON "image" (url, rank, product_id) WHERE deleted_at IS NULL;`
19 )
20 this.addSql(
21 `CREATE INDEX IF NOT EXISTS "IDX_product_image_rank_product_id" ON "image" (rank, product_id) WHERE deleted_at IS NULL;`
22 )
23 }
24
25 override async down(): Promise<void> {
26 this.addSql(`drop index if exists "IDX_image_product_id";`)
27 this.addSql(`drop index if exists "IDX_image_deleted_at";`)
28 this.addSql(`drop index if exists "IDX_product_image_url";`)
29 this.addSql(`drop index if exists "IDX_product_image_rank";`)
30 this.addSql(`drop index if exists "IDX_product_image_url_rank_product_id";`)
31 this.addSql(`drop index if exists "IDX_product_image_rank_product_id";`)
32 }
33 }