|
1
|
import { Migration } from "@medusajs/framework/mikro-orm/migrations" |
|
2
|
|
|
3
|
export class Migration20241205122700 extends Migration { |
|
4
|
async up(): Promise<void> { |
|
5
|
this.addSql( |
|
6
|
'alter table if exists "api_key" add column if not exists "deleted_at" timestamptz null;' |
|
7
|
) |
|
8
|
this.addSql( |
|
9
|
'alter table if exists "api_key" alter column "type" type text using ("type"::text);' |
|
10
|
) |
|
11
|
this.addSql( |
|
12
|
'alter table if exists "api_key" add constraint "api_key_type_check" check ("type" in (\'publishable\', \'secret\'));' |
|
13
|
) |
|
14
|
this.addSql( |
|
15
|
'CREATE INDEX IF NOT EXISTS "IDX_api_key_deleted_at" ON "api_key" (deleted_at) WHERE deleted_at IS NULL;' |
|
16
|
) |
|
17
|
} |
|
18
|
|
|
19
|
async down(): Promise<void> { |
|
20
|
this.addSql( |
|
21
|
'alter table if exists "api_key" drop constraint if exists "api_key_type_check";' |
|
22
|
) |
|
23
|
|
|
24
|
this.addSql( |
|
25
|
'alter table if exists "api_key" alter column "type" type text using ("type"::text);' |
|
26
|
) |
|
27
|
this.addSql('drop index if exists "IDX_api_key_deleted_at";') |
|
28
|
this.addSql( |
|
29
|
'alter table if exists "api_key" drop column if exists "deleted_at";' |
|
30
|
) |
|
31
|
} |
|
32
|
} |