1 import { model } from "@medusajs/framework/utils";
2 import AccountTransaction from "./account-transaction";
3
4 export default model
5 .define(
6 { tableName: "store_credit_account", name: "StoreCreditAccount" },
7 {
8 id: model.id({ prefix: "sc_acc" }).primaryKey(),
9 code: model.text().nullable(),
10 currency_code: model.text().searchable(),
11 customer_id: model.text().nullable(),
12 metadata: model.json().nullable(),
13
14 transactions: model.hasMany(() => AccountTransaction, {
15 mappedBy: "account",
16 }),
17 }
18 )
19 .indexes([
20 {
21 name: "IDX_customer_id_currency_code",
22 on: ["customer_id", "currency_code"],
23 unique: true,
24 where: "customer_id IS NOT NULL",
25 },
26 ]);