chore(payment): Payment module DML (#10553)
* chore(payment): Payment module DML * rm log * migration
This commit is contained in:
committed by
GitHub
parent
91cd9aad47
commit
0264294ab5
@@ -1,77 +1,21 @@
|
||||
import { BigNumberRawValue } from "@medusajs/framework/types"
|
||||
import {
|
||||
BigNumber,
|
||||
MikroOrmBigNumberProperty,
|
||||
generateEntityId,
|
||||
} from "@medusajs/framework/utils"
|
||||
import {
|
||||
BeforeCreate,
|
||||
Entity,
|
||||
ManyToOne,
|
||||
OnInit,
|
||||
OptionalProps,
|
||||
PrimaryKey,
|
||||
Property,
|
||||
} from "@mikro-orm/core"
|
||||
import { model } from "@medusajs/framework/utils"
|
||||
import Payment from "./payment"
|
||||
|
||||
type OptionalCaptureProps = "created_at"
|
||||
|
||||
@Entity({ tableName: "capture" })
|
||||
export default class Capture {
|
||||
[OptionalProps]?: OptionalCaptureProps
|
||||
|
||||
@PrimaryKey({ columnType: "text" })
|
||||
id: string
|
||||
|
||||
@MikroOrmBigNumberProperty()
|
||||
amount: BigNumber | number
|
||||
|
||||
@Property({ columnType: "jsonb" })
|
||||
raw_amount: BigNumberRawValue
|
||||
|
||||
@ManyToOne(() => Payment, {
|
||||
onDelete: "cascade",
|
||||
index: "IDX_capture_payment_id",
|
||||
fieldName: "payment_id",
|
||||
const Capture = model
|
||||
.define("Capture", {
|
||||
id: model.id({ prefix: "capt" }).primaryKey(),
|
||||
amount: model.bigNumber(),
|
||||
payment: model.belongsTo(() => Payment, {
|
||||
mappedBy: "captures",
|
||||
}),
|
||||
metadata: model.json().nullable(),
|
||||
created_by: model.text().nullable(),
|
||||
})
|
||||
payment!: Payment
|
||||
.indexes([
|
||||
{
|
||||
name: "IDX_capture_payment_id",
|
||||
on: ["payment_id"],
|
||||
},
|
||||
])
|
||||
|
||||
@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,
|
||||
index: "IDX_capture_deleted_at",
|
||||
})
|
||||
deleted_at: Date | null = null
|
||||
|
||||
@Property({ columnType: "text", nullable: true })
|
||||
created_by: string | null = null
|
||||
|
||||
@BeforeCreate()
|
||||
onCreate() {
|
||||
this.id = generateEntityId(this.id, "capt")
|
||||
}
|
||||
|
||||
@OnInit()
|
||||
onInit() {
|
||||
this.id = generateEntityId(this.id, "capt")
|
||||
}
|
||||
}
|
||||
export default Capture
|
||||
|
||||
Reference in New Issue
Block a user