|
1
|
import { Migration } from "@medusajs/framework/mikro-orm/migrations" |
|
2
|
|
|
3
|
export class Migration20250113094144 extends Migration { |
|
4
|
async up(): Promise<void> { |
|
5
|
this.addSql( |
|
6
|
"alter table if exists \"promotion\" add column if not exists \"status\" text check (\"status\" in ('draft', 'active', 'inactive')) not null default 'draft';" |
|
7
|
) |
|
8
|
|
|
9
|
this.addSql( |
|
10
|
'CREATE INDEX IF NOT EXISTS "IDX_promotion_status" ON "promotion" (status) WHERE deleted_at IS NULL;' |
|
11
|
) |
|
12
|
|
|
13
|
// Data Migration |
|
14
|
this.addSql(`UPDATE promotion SET status = 'active';`) |
|
15
|
} |
|
16
|
|
|
17
|
async down(): Promise<void> { |
|
18
|
this.addSql('drop index if exists "IDX_promotion_status";') |
|
19
|
this.addSql( |
|
20
|
'alter table if exists "promotion" drop column if exists "status";' |
|
21
|
) |
|
22
|
} |
|
23
|
} |