Files
medusa-store/packages/modules/pricing/src/models/price-rule.ts
Adrien de Peretti c54c5ed6de chore(): improve cart operations + Mikro orm 6.4.16 (#13712)
* chore(): Mikro orm 6.4.16

* Create small-ghosts-draw.md

* update config

* update config

* fix delete

* update config

* update workflows

* order improvements

* test pricing quuery

* test pricing quuery

* configurable connection options

* configurable connection options

* configurable connection options

* Update packages/modules/pricing/src/models/price.ts

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2025-10-10 08:58:19 +02:00

40 lines
952 B
TypeScript

import { model, PricingRuleOperator } from "@medusajs/framework/utils"
import Price from "./price"
const PriceRule = model
.define("PriceRule", {
id: model.id({ prefix: "prule" }).primaryKey(),
attribute: model.text(),
value: model.text(),
operator: model.enum(PricingRuleOperator).default(PricingRuleOperator.EQ),
priority: model.number().default(0),
price: model.belongsTo(() => Price, {
mappedBy: "price_rules",
}),
})
.indexes([
{
on: ["price_id", "attribute", "operator"],
where: "deleted_at IS NULL",
unique: true,
},
{
on: ["attribute"],
where: "deleted_at IS NULL",
},
{
on: ["attribute", "value"],
where: "deleted_at IS NULL",
},
{
on: ["operator", "value"],
where: "deleted_at IS NULL",
},
{
on: ["attribute", "value", "price_id"],
where: "deleted_at IS NULL",
},
])
export default PriceRule