|
1
|
import { Migration } from "@medusajs/framework/mikro-orm/migrations" |
|
2
|
|
|
3
|
export class Migration20241217162224 extends Migration { |
|
4
|
async up(): Promise<void> { |
|
5
|
this.addSql( |
|
6
|
'create table if not exists "order_credit_line" ("id" text not null, "order_id" text not null, "reference" text null, "reference_id" text null, "amount" numeric not null, "raw_amount" jsonb not null, "metadata" jsonb null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "order_credit_line_pkey" primary key ("id"));' |
|
7
|
) |
|
8
|
|
|
9
|
this.addSql( |
|
10
|
'CREATE INDEX IF NOT EXISTS "IDX_order_credit_line_order_id" ON "order_credit_line" (order_id) WHERE deleted_at IS NOT NULL;' |
|
11
|
) |
|
12
|
|
|
13
|
this.addSql( |
|
14
|
'CREATE INDEX IF NOT EXISTS "IDX_order_credit_line_deleted_at" ON "order_credit_line" (deleted_at) WHERE deleted_at IS NOT NULL;' |
|
15
|
) |
|
16
|
|
|
17
|
this.addSql( |
|
18
|
'alter table if exists "order_credit_line" add constraint "order_credit_line_order_id_foreign" foreign key ("order_id") references "order" ("id") on update cascade;' |
|
19
|
) |
|
20
|
} |
|
21
|
|
|
22
|
async down(): Promise<void> { |
|
23
|
this.addSql('drop table if exists "order_credit_line" cascade;') |
|
24
|
} |
|
25
|
} |