|
1
|
import { Migration } from "@medusajs/framework/mikro-orm/migrations"; |
|
2
|
|
|
3
|
export class Migration20250130213237 extends Migration { |
|
4
|
async up(): Promise<void> { |
|
5
|
this.addSql( |
|
6
|
'create table if not exists "store_credit_transaction_group" ("id" text not null, "code" text not null, "account_id" text not null, "metadata" jsonb null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "store_credit_transaction_group_pkey" primary key ("id"));' |
|
7
|
); |
|
8
|
|
|
9
|
this.addSql( |
|
10
|
'CREATE UNIQUE INDEX IF NOT EXISTS "IDX_store_credit_transaction_group_code_unique" ON "store_credit_transaction_group" (code) WHERE deleted_at IS NULL;' |
|
11
|
); |
|
12
|
|
|
13
|
this.addSql( |
|
14
|
'CREATE INDEX IF NOT EXISTS "IDX_store_credit_transaction_group_account_id" ON "store_credit_transaction_group" (account_id) WHERE deleted_at IS NULL;' |
|
15
|
); |
|
16
|
|
|
17
|
this.addSql( |
|
18
|
'CREATE INDEX IF NOT EXISTS "IDX_store_credit_transaction_group_deleted_at" ON "store_credit_transaction_group" (deleted_at) WHERE deleted_at IS NULL;' |
|
19
|
); |
|
20
|
|
|
21
|
this.addSql( |
|
22
|
'alter table if exists "store_credit_transaction_group" add constraint "store_credit_transaction_group_account_id_foreign" foreign key ("account_id") references "store_credit_account" ("id") on update cascade;' |
|
23
|
); |
|
24
|
} |
|
25
|
|
|
26
|
async down(): Promise<void> { |
|
27
|
this.addSql( |
|
28
|
'drop table if exists "store_credit_transaction_group" cascade;' |
|
29
|
); |
|
30
|
} |
|
31
|
} |