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