1 import { model } from "@medusajs/framework/utils"
2 import ShippingMethod from "./shipping-method"
3
4 const ShippingMethodAdjustment = model
5 .define(
6 {
7 name: "ShippingMethodAdjustment",
8 tableName: "cart_shipping_method_adjustment",
9 },
10 {
11 id: model.id({ prefix: "casmadj" }).primaryKey(),
12 description: model.text().nullable(),
13 code: model.text().nullable(),
14 amount: model.bigNumber(),
15 provider_id: model.text().nullable(),
16 metadata: model.json().nullable(),
17 promotion_id: model.text().nullable(),
18 shipping_method: model.belongsTo(() => ShippingMethod, {
19 mappedBy: "adjustments",
20 }),
21 }
22 )
23 .indexes([
24 {
25 name: "IDX_shipping_method_adjustment_promotion_id",
26 on: ["promotion_id"],
27 where: "deleted_at IS NULL AND promotion_id IS NOT NULL",
28 },
29 {
30 name: "IDX_cart_shipping_method_adjustment_shipping_method_id",
31 on: ["shipping_method_id"],
32 where: "deleted_at IS NULL",
33 },
34 ])
35
36 export default ShippingMethodAdjustment