|
1
|
import { model } from "@medusajs/framework/utils" |
|
2
|
import { OrderClaim } from "./claim" |
|
3
|
import { OrderExchange } from "./exchange" |
|
4
|
import { Order } from "./order" |
|
5
|
import { Return } from "./return" |
|
6
|
import { OrderShippingMethod } from "./shipping-method" |
|
7
|
|
|
8
|
const _OrderShipping = model |
|
9
|
.define("OrderShipping", { |
|
10
|
id: model.id({ prefix: "ordspmv" }).primaryKey(), |
|
11
|
version: model.number().default(1), |
|
12
|
order: model.belongsTo<() => typeof Order>(() => Order, { |
|
13
|
mappedBy: "shipping_methods", |
|
14
|
}), |
|
15
|
return: model |
|
16
|
.belongsTo<() => typeof Return>(() => Return, { |
|
17
|
mappedBy: "shipping_methods", |
|
18
|
}) |
|
19
|
.nullable(), |
|
20
|
exchange: model |
|
21
|
.belongsTo<() => typeof OrderExchange>(() => OrderExchange, { |
|
22
|
mappedBy: "shipping_methods", |
|
23
|
}) |
|
24
|
.nullable(), |
|
25
|
claim: model |
|
26
|
.belongsTo<() => typeof OrderClaim>(() => OrderClaim, { |
|
27
|
mappedBy: "shipping_methods", |
|
28
|
}) |
|
29
|
.nullable(), |
|
30
|
shipping_method: model.hasOne<() => typeof OrderShippingMethod>( |
|
31
|
() => OrderShippingMethod, |
|
32
|
{ |
|
33
|
mappedBy: undefined, |
|
34
|
foreignKey: true, |
|
35
|
} |
|
36
|
), |
|
37
|
}) |
|
38
|
.indexes([ |
|
39
|
{ |
|
40
|
name: "IDX_order_shipping_order_id", |
|
41
|
on: ["order_id"], |
|
42
|
unique: false, |
|
43
|
where: "deleted_at IS NULL", |
|
44
|
}, |
|
45
|
{ |
|
46
|
name: "IDX_order_shipping_return_id", |
|
47
|
on: ["return_id"], |
|
48
|
unique: false, |
|
49
|
where: "return_id IS NOT NULL AND deleted_at IS NULL", |
|
50
|
}, |
|
51
|
{ |
|
52
|
name: "IDX_order_shipping_exchange_id", |
|
53
|
on: ["exchange_id"], |
|
54
|
unique: false, |
|
55
|
where: "exchange_id IS NOT NULL AND deleted_at IS NULL", |
|
56
|
}, |
|
57
|
{ |
|
58
|
name: "IDX_order_shipping_claim_id", |
|
59
|
on: ["claim_id"], |
|
60
|
unique: false, |
|
61
|
where: "claim_id IS NOT NULL AND deleted_at IS NULL", |
|
62
|
}, |
|
63
|
{ |
|
64
|
name: "IDX_order_shipping_order_id_version", |
|
65
|
on: ["order_id", "version"], |
|
66
|
unique: false, |
|
67
|
where: "deleted_at IS NULL", |
|
68
|
}, |
|
69
|
{ |
|
70
|
name: "IDX_order_shipping_shipping_method_id", |
|
71
|
on: ["shipping_method_id"], |
|
72
|
unique: false, |
|
73
|
where: "deleted_at IS NULL", |
|
74
|
}, |
|
75
|
{ |
|
76
|
name: "IDX_order_shipping_deleted_at", |
|
77
|
on: ["deleted_at"], |
|
78
|
unique: false, |
|
79
|
where: "deleted_at IS NOT NULL", |
|
80
|
}, |
|
81
|
]) |
|
82
|
|
|
83
|
export const OrderShipping = _OrderShipping |