|
1
|
import { Migration } from "@medusajs/framework/mikro-orm/migrations" |
|
2
|
|
|
3
|
export class Migration20250929204438 extends Migration { |
|
4
|
override async up(): Promise<void> { |
|
5
|
this.addSql( |
|
6
|
`create table if not exists "product_variant_product_image" ( |
|
7
|
"id" text not null, |
|
8
|
"variant_id" text not null, |
|
9
|
"image_id" text not null, |
|
10
|
"created_at" timestamptz not null default now(), |
|
11
|
"updated_at" timestamptz not null default now(), |
|
12
|
"deleted_at" timestamptz null, |
|
13
|
constraint "product_variant_product_image_pkey" primary key ("id"), |
|
14
|
constraint "product_variant_product_image_image_id_foreign" |
|
15
|
foreign key ("image_id") references "image" ("id") on delete cascade |
|
16
|
);` |
|
17
|
) |
|
18
|
this.addSql( |
|
19
|
`CREATE INDEX IF NOT EXISTS "IDX_product_variant_product_image_variant_id" ON "product_variant_product_image" (variant_id) WHERE deleted_at IS NULL;` |
|
20
|
) |
|
21
|
this.addSql( |
|
22
|
`CREATE INDEX IF NOT EXISTS "IDX_product_variant_product_image_image_id" ON "product_variant_product_image" (image_id) WHERE deleted_at IS NULL;` |
|
23
|
) |
|
24
|
this.addSql( |
|
25
|
`CREATE INDEX IF NOT EXISTS "IDX_product_variant_product_image_deleted_at" ON "product_variant_product_image" (deleted_at) WHERE deleted_at IS NULL;` |
|
26
|
) |
|
27
|
} |
|
28
|
|
|
29
|
override async down(): Promise<void> { |
|
30
|
this.addSql(`drop table if exists "product_variant_product_image" cascade;`) |
|
31
|
} |
|
32
|
} |