|
1
|
import { Migration } from "@medusajs/framework/mikro-orm/migrations" |
|
2
|
|
|
3
|
export class Migration20250226130616 extends Migration { |
|
4
|
override async up(): Promise<void> { |
|
5
|
this.addSql( |
|
6
|
'alter table if exists "promotion" drop constraint if exists "IDX_promotion_code_unique";' |
|
7
|
) |
|
8
|
this.addSql(`drop index if exists "IDX_promotion_code_unique";`) |
|
9
|
this.addSql(`drop index if exists "IDX_promotion_code";`) |
|
10
|
this.addSql( |
|
11
|
`CREATE UNIQUE INDEX IF NOT EXISTS "IDX_unique_promotion_code" ON "promotion" (code) WHERE deleted_at IS NULL;` |
|
12
|
) |
|
13
|
} |
|
14
|
|
|
15
|
override async down(): Promise<void> { |
|
16
|
this.addSql(`drop index if exists "IDX_unique_promotion_code";`) |
|
17
|
|
|
18
|
this.addSql( |
|
19
|
`CREATE UNIQUE INDEX IF NOT EXISTS "IDX_promotion_code_unique" ON "promotion" (code) WHERE deleted_at IS NULL;` |
|
20
|
) |
|
21
|
this.addSql( |
|
22
|
`CREATE INDEX IF NOT EXISTS "IDX_promotion_code" ON "promotion" (code) WHERE deleted_at IS NULL;` |
|
23
|
) |
|
24
|
} |
|
25
|
} |