chore(payment): Payment module DML (#10553)

* chore(payment): Payment module DML

* rm log

* migration
This commit is contained in:
Carlos R. L. Rodrigues
2024-12-11 13:09:10 -03:00
committed by GitHub
parent 91cd9aad47
commit 0264294ab5
14 changed files with 706 additions and 1039 deletions

View File

@@ -1,58 +1,14 @@
import {
DALUtils,
generateEntityId,
Searchable,
} from "@medusajs/framework/utils"
import {
BeforeCreate,
Entity,
Filter,
OnInit,
PrimaryKey,
Property,
} from "@mikro-orm/core"
import { model } from "@medusajs/framework/utils"
import Refund from "./refund"
@Entity({ tableName: "refund_reason" })
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
export default class RefundReason {
@PrimaryKey({ columnType: "text" })
id: string
const RefundReason = model.define("RefundReason", {
id: model.id({ prefix: "refr" }).primaryKey(),
label: model.text().searchable(),
description: model.text().nullable(),
metadata: model.json().nullable(),
refunds: model.hasMany(() => Refund, {
mappedBy: "refund_reason",
}),
})
@Searchable()
@Property({ columnType: "text" })
label: string
@Property({ columnType: "text", nullable: true })
description: string | null = null
@Property({ columnType: "jsonb", nullable: true })
metadata: Record<string, unknown> | null = null
@Property({
onCreate: () => new Date(),
columnType: "timestamptz",
defaultRaw: "now()",
})
created_at: Date
@Property({
onCreate: () => new Date(),
onUpdate: () => new Date(),
columnType: "timestamptz",
defaultRaw: "now()",
})
updated_at: Date
@Property({ columnType: "timestamptz", nullable: true })
deleted_at: Date | null = null
@BeforeCreate()
onCreate() {
this.id = generateEntityId(this.id, "refr")
}
@OnInit()
onInit() {
this.id = generateEntityId(this.id, "refr")
}
}
export default RefundReason