1 import { Migration } from "@medusajs/framework/mikro-orm/migrations";
2
3 export class Migration20250129115518 extends Migration {
4 async up(): Promise<void> {
5 this.addSql(
6 'create table if not exists "store_credit_account" ("id" text not null, "currency_code" text not null, "customer_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_account_pkey" primary key ("id"));'
7 );
8
9 this.addSql(
10 'CREATE INDEX IF NOT EXISTS "IDX_store_credit_account_deleted_at" ON "store_credit_account" (deleted_at) WHERE deleted_at IS NULL;'
11 );
12
13 this.addSql(
14 'CREATE UNIQUE INDEX IF NOT EXISTS "IDX_customer_id_currency_code" ON "store_credit_account" (customer_id, currency_code) WHERE deleted_at IS NULL;'
15 );
16 }
17
18 async down(): Promise<void> {
19 this.addSql('drop table if exists "store_credit_account" cascade;');
20 }
21 }