|
1
|
import { generatePostgresAlterColummnIfExistStatement } from "@medusajs/framework/utils" |
|
2
|
import { Migration } from "@medusajs/framework/mikro-orm/migrations" |
|
3
|
|
|
4
|
export class Migration20240624200006 extends Migration { |
|
5
|
async up(): Promise<void> { |
|
6
|
this.addSql( |
|
7
|
'ALTER TABLE IF EXISTS "region_country" ADD COLUMN IF NOT EXISTS "metadata" jsonb null, ADD COLUMN "created_at" timestamptz NOT NULL DEFAULT NOW(), ADD COLUMN "updated_at" timestamptz NOT NULL DEFAULT NOW(), ADD COLUMN "deleted_at" timestamptz NULL;' |
|
8
|
) |
|
9
|
this.addSql( |
|
10
|
generatePostgresAlterColummnIfExistStatement( |
|
11
|
"region_country", |
|
12
|
["region_id"], |
|
13
|
`DROP NOT NULL` |
|
14
|
) |
|
15
|
) |
|
16
|
} |
|
17
|
|
|
18
|
async down(): Promise<void> { |
|
19
|
this.addSql( |
|
20
|
'ALTER TABLE IF EXISTS "region_country" DROP COLUMN IF EXISTS "metadata";' |
|
21
|
) |
|
22
|
this.addSql( |
|
23
|
'ALTER TABLE IF EXISTS "region_country" DROP COLUMN IF EXISTS "created_at";' |
|
24
|
) |
|
25
|
this.addSql( |
|
26
|
'ALTER TABLE IF EXISTS "region_country" DROP COLUMN IF EXISTS "updated_at";' |
|
27
|
) |
|
28
|
this.addSql( |
|
29
|
'ALTER TABLE IF EXISTS "region_country" DROP COLUMN IF EXISTS "deleted_at";' |
|
30
|
) |
|
31
|
this.addSql( |
|
32
|
generatePostgresAlterColummnIfExistStatement( |
|
33
|
"region_country", |
|
34
|
["region_id"], |
|
35
|
`SET NOT NULL` |
|
36
|
) |
|
37
|
) |
|
38
|
} |
|
39
|
} |