1 import { Migration } from "@medusajs/framework/mikro-orm/migrations"
2
3 export class Migration20241210073813 extends Migration {
4 async up(): Promise<void> {
5 this.addSql(
6 'alter table if exists "stock_location" drop constraint if exists "stock_location_address_id_foreign";'
7 )
8
9 this.addSql(
10 'alter table if exists "stock_location" add constraint "stock_location_address_id_foreign" foreign key ("address_id") references "stock_location_address" ("id") on update cascade on delete cascade;'
11 )
12 this.addSql(
13 'CREATE INDEX IF NOT EXISTS "IDX_stock_location_address_id" ON "stock_location" (address_id) WHERE deleted_at IS NULL;'
14 )
15 }
16
17 async down(): Promise<void> {
18 this.addSql(
19 'alter table if exists "stock_location" drop constraint if exists "stock_location_address_id_foreign";'
20 )
21
22 this.addSql('drop index if exists "IDX_stock_location_address_id";')
23 this.addSql(
24 'alter table if exists "stock_location" add constraint "stock_location_address_id_foreign" foreign key ("address_id") references "stock_location_address" ("id") on update cascade on delete set null;'
25 )
26 }
27 }