chore: locking-postgres provider dml (#10478)

This commit is contained in:
Carlos R. L. Rodrigues
2024-12-06 10:14:14 -03:00
committed by GitHub
parent f65a3cc06d
commit b0448a7c35
5 changed files with 153 additions and 172 deletions

View File

@@ -1,32 +1,9 @@
import { generateEntityId } from "@medusajs/framework/utils"
import {
BeforeCreate,
Entity,
OnInit,
PrimaryKey,
Property,
} from "@mikro-orm/core"
import { model } from "@medusajs/framework/utils"
@Entity({ tableName: "locking" })
class Locking {
@PrimaryKey({ columnType: "text" })
id!: string
@Property({ columnType: "text", nullable: true })
owner_id: string | null = null
@Property({ columnType: "timestamptz", nullable: true })
expiration: Date | null = null
@BeforeCreate()
onCreate() {
this.id = generateEntityId(this.id, "lk")
}
@OnInit()
onInit() {
this.id = generateEntityId(this.id, "lk")
}
}
const Locking = model.define("Locking", {
id: model.id({ prefix: "lk" }).primaryKey(),
owner_id: model.text().nullable(),
expiration: model.dateTime().nullable(),
})
export default Locking