1 import { model } from "@medusajs/framework/utils"
2 import { OrderShippingMethod } from "./shipping-method"
3
4 const _OrderShippingMethodAdjustment = model
5 .define(
6 {
7 tableName: "order_shipping_method_adjustment",
8 name: "OrderShippingMethodAdjustment",
9 },
10 {
11 id: model.id({ prefix: "ordsmadj" }).primaryKey(),
12 version: model.number().default(1),
13 description: model.text().nullable(),
14 promotion_id: model.text().nullable(),
15 code: model.text().nullable(),
16 amount: model.bigNumber(),
17 provider_id: model.text().nullable(),
18 shipping_method: model.belongsTo<() => typeof OrderShippingMethod>(
19 () => OrderShippingMethod,
20 {
21 mappedBy: "adjustments",
22 }
23 ),
24 }
25 )
26 .indexes([
27 {
28 name: "IDX_order_shipping_method_adjustment_shipping_method_id",
29 on: ["shipping_method_id"],
30 unique: false,
31 },
32 {
33 name: "IDX_order_shipping_method_adjustment_version_shipping_method",
34 on: ["version", "shipping_method_id"],
35 unique: true,
36 where: "deleted_at IS NULL",
37 },
38 ])
39
40 /**
41 * The Order Shipping Method Adjustment data model. This model represents adjustments applied to
42 * order shipping methods, such as promotions or discounts.
43 *
44 * @since 2.13.7
45 */
46 export const OrderShippingMethodAdjustment = _OrderShippingMethodAdjustment