feat(): prefilter top level promotion rules in db (#13524)
* feat(): promotion pre filtering rule from db * wip * feat(): promotion pre filtering rule from db * improve test readability * resolve conflict * fix automatic flag * add index on attribute and operator * add index on attribute and operator * finalize * cleanup * cleanup * cleanup * cleanup * Create purple-cars-design.md * fixes * fixes * simplify filters * fix filter * fix filter * further improvements * fixes * fixes * fixes * fix exclusion * fix comment * fix comment
This commit is contained in:
@@ -1,15 +1,30 @@
|
||||
import { model } from "@medusajs/framework/utils"
|
||||
import PromotionRule from "./promotion-rule"
|
||||
|
||||
const PromotionRuleValue = model.define(
|
||||
{ name: "PromotionRuleValue", tableName: "promotion_rule_value" },
|
||||
{
|
||||
id: model.id({ prefix: "prorulval" }).primaryKey(),
|
||||
value: model.text(),
|
||||
promotion_rule: model.belongsTo(() => PromotionRule, {
|
||||
mappedBy: "values",
|
||||
}),
|
||||
}
|
||||
)
|
||||
const PromotionRuleValue = model
|
||||
.define(
|
||||
{ name: "PromotionRuleValue", tableName: "promotion_rule_value" },
|
||||
{
|
||||
id: model.id({ prefix: "prorulval" }).primaryKey(),
|
||||
value: model.text(),
|
||||
promotion_rule: model.belongsTo(() => PromotionRule, {
|
||||
mappedBy: "values",
|
||||
}),
|
||||
}
|
||||
)
|
||||
.indexes([
|
||||
{
|
||||
name: "IDX_promotion_rule_value_rule_id_value",
|
||||
on: ["promotion_rule_id", "value"],
|
||||
unique: false,
|
||||
where: "deleted_at IS NULL",
|
||||
},
|
||||
{
|
||||
name: "IDX_promotion_rule_value_value",
|
||||
on: ["value"],
|
||||
unique: false,
|
||||
where: "deleted_at IS NULL",
|
||||
},
|
||||
])
|
||||
|
||||
export default PromotionRuleValue
|
||||
|
||||
@@ -30,6 +30,13 @@ const PromotionRule = model
|
||||
}),
|
||||
}
|
||||
)
|
||||
.indexes([
|
||||
{
|
||||
on: ["attribute", "operator"],
|
||||
unique: false,
|
||||
where: "deleted_at IS NULL",
|
||||
},
|
||||
])
|
||||
.cascades({
|
||||
delete: ["values"],
|
||||
})
|
||||
|
||||
@@ -39,6 +39,12 @@ const Promotion = model
|
||||
where: "deleted_at IS NULL",
|
||||
unique: true,
|
||||
},
|
||||
{
|
||||
name: "IDX_promotion_is_automatic",
|
||||
on: ["is_automatic"],
|
||||
unique: false,
|
||||
where: "deleted_at IS NULL",
|
||||
},
|
||||
])
|
||||
|
||||
export default Promotion
|
||||
|
||||
Reference in New Issue
Block a user