|
1
|
import { Migration } from "@medusajs/framework/mikro-orm/migrations" |
|
2
|
|
|
3
|
export class Migration20250120115002 extends Migration { |
|
4
|
async up(): Promise<void> { |
|
5
|
this.addSql( |
|
6
|
'alter table if exists "shipping_option" add constraint "shipping_option_provider_id_foreign" foreign key ("provider_id") references "fulfillment_provider" ("id") on update cascade on delete set null;' |
|
7
|
) |
|
8
|
this.addSql( |
|
9
|
'alter table if exists "shipping_option" add constraint "shipping_option_shipping_option_type_id_foreign" foreign key ("shipping_option_type_id") references "shipping_option_type" ("id") on update cascade;' |
|
10
|
) |
|
11
|
this.addSql( |
|
12
|
'CREATE INDEX IF NOT EXISTS "IDX_shipping_option_provider_id" ON "shipping_option" (provider_id) WHERE deleted_at IS NULL;' |
|
13
|
) |
|
14
|
|
|
15
|
this.addSql( |
|
16
|
'alter table if exists "fulfillment" add constraint "fulfillment_provider_id_foreign" foreign key ("provider_id") references "fulfillment_provider" ("id") on update cascade on delete set null;' |
|
17
|
) |
|
18
|
this.addSql( |
|
19
|
'alter table if exists "fulfillment" add constraint "fulfillment_delivery_address_id_foreign" foreign key ("delivery_address_id") references "fulfillment_address" ("id") on update cascade on delete set null;' |
|
20
|
) |
|
21
|
} |
|
22
|
|
|
23
|
async down(): Promise<void> { |
|
24
|
this.addSql( |
|
25
|
'alter table if exists "shipping_option" drop constraint if exists "shipping_option_provider_id_foreign";' |
|
26
|
) |
|
27
|
this.addSql( |
|
28
|
'alter table if exists "shipping_option" drop constraint if exists "shipping_option_shipping_option_type_id_foreign";' |
|
29
|
) |
|
30
|
|
|
31
|
this.addSql( |
|
32
|
'alter table if exists "fulfillment" drop constraint if exists "fulfillment_provider_id_foreign";' |
|
33
|
) |
|
34
|
this.addSql( |
|
35
|
'alter table if exists "fulfillment" drop constraint if exists "fulfillment_delivery_address_id_foreign";' |
|
36
|
) |
|
37
|
|
|
38
|
this.addSql('drop index if exists "IDX_shipping_option_provider_id";') |
|
39
|
} |
|
40
|
} |