Fixes: FRMW-2810 ## Breaking changes There is only one breaking change - The `min_quantity` and `max_quantity` properties are now consistently typed as numbers. Earlier, it was [typed as numbers](https://github.com/medusajs/medusa/blob/develop/integration-tests/http/__tests__/price-list/admin/price-list.spec.ts#L68-L69) in some API responses and as [string in others](https://github.com/medusajs/medusa/blob/develop/integration-tests/http/__tests__/price-list/admin/price-list.spec.ts#L186-L187). I did not go to the bottom of this inconsistency, but the tests reveals them. Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
46 lines
1.1 KiB
TypeScript
46 lines
1.1 KiB
TypeScript
import { model } from "@medusajs/framework/utils"
|
|
import PriceList from "./price-list"
|
|
import PriceRule from "./price-rule"
|
|
import PriceSet from "./price-set"
|
|
|
|
const Price = model
|
|
.define("Price", {
|
|
id: model.id({ prefix: "price" }).primaryKey(),
|
|
title: model.text().nullable(),
|
|
currency_code: model.text(),
|
|
amount: model.bigNumber(),
|
|
min_quantity: model.number().nullable(),
|
|
max_quantity: model.number().nullable(),
|
|
rules_count: model.number().default(0).nullable(),
|
|
price_set: model.belongsTo(() => PriceSet, {
|
|
mappedBy: "prices",
|
|
}),
|
|
price_rules: model.hasMany(() => PriceRule, {
|
|
mappedBy: "price",
|
|
}),
|
|
price_list: model
|
|
.belongsTo(() => PriceList, {
|
|
mappedBy: "prices",
|
|
})
|
|
.nullable(),
|
|
})
|
|
.cascades({
|
|
delete: ["price_rules"],
|
|
})
|
|
.indexes([
|
|
{
|
|
on: ["price_set_id"],
|
|
where: "deleted_at IS NULL",
|
|
},
|
|
{
|
|
on: ["price_list_id"],
|
|
where: "deleted_at IS NULL",
|
|
},
|
|
{
|
|
on: ["currency_code"],
|
|
where: "deleted_at IS NULL",
|
|
},
|
|
])
|
|
|
|
export default Price
|