|
1
|
import { Migration } from "@medusajs/framework/mikro-orm/migrations" |
|
2
|
|
|
3
|
export class Migration20251114100559 extends Migration { |
|
4
|
override async up(): Promise<void> { |
|
5
|
this.addSql( |
|
6
|
`alter table if exists "order" add column if not exists "custom_display_id" text null;` |
|
7
|
) |
|
8
|
this.addSql( |
|
9
|
`CREATE UNIQUE INDEX IF NOT EXISTS "IDX_order_custom_display_id" ON "order" ("custom_display_id") WHERE deleted_at IS NULL;` |
|
10
|
) |
|
11
|
|
|
12
|
this.addSql( |
|
13
|
`alter table if exists "order_item" alter column "raw_fulfilled_quantity" type jsonb using ("raw_fulfilled_quantity"::jsonb);` |
|
14
|
) |
|
15
|
this.addSql( |
|
16
|
`alter table if exists "order_item" alter column "raw_fulfilled_quantity" set default '{"value":"0","precision":20}';` |
|
17
|
) |
|
18
|
this.addSql( |
|
19
|
`alter table if exists "order_item" alter column "raw_delivered_quantity" type jsonb using ("raw_delivered_quantity"::jsonb);` |
|
20
|
) |
|
21
|
this.addSql( |
|
22
|
`alter table if exists "order_item" alter column "raw_delivered_quantity" set default '{"value":"0","precision":20}';` |
|
23
|
) |
|
24
|
this.addSql( |
|
25
|
`alter table if exists "order_item" alter column "raw_shipped_quantity" type jsonb using ("raw_shipped_quantity"::jsonb);` |
|
26
|
) |
|
27
|
this.addSql( |
|
28
|
`alter table if exists "order_item" alter column "raw_shipped_quantity" set default '{"value":"0","precision":20}';` |
|
29
|
) |
|
30
|
this.addSql( |
|
31
|
`alter table if exists "order_item" alter column "raw_return_requested_quantity" type jsonb using ("raw_return_requested_quantity"::jsonb);` |
|
32
|
) |
|
33
|
this.addSql( |
|
34
|
`alter table if exists "order_item" alter column "raw_return_requested_quantity" set default '{"value":"0","precision":20}';` |
|
35
|
) |
|
36
|
this.addSql( |
|
37
|
`alter table if exists "order_item" alter column "raw_return_received_quantity" type jsonb using ("raw_return_received_quantity"::jsonb);` |
|
38
|
) |
|
39
|
this.addSql( |
|
40
|
`alter table if exists "order_item" alter column "raw_return_received_quantity" set default '{"value":"0","precision":20}';` |
|
41
|
) |
|
42
|
this.addSql( |
|
43
|
`alter table if exists "order_item" alter column "raw_return_dismissed_quantity" type jsonb using ("raw_return_dismissed_quantity"::jsonb);` |
|
44
|
) |
|
45
|
this.addSql( |
|
46
|
`alter table if exists "order_item" alter column "raw_return_dismissed_quantity" set default '{"value":"0","precision":20}';` |
|
47
|
) |
|
48
|
this.addSql( |
|
49
|
`alter table if exists "order_item" alter column "raw_written_off_quantity" type jsonb using ("raw_written_off_quantity"::jsonb);` |
|
50
|
) |
|
51
|
this.addSql( |
|
52
|
`alter table if exists "order_item" alter column "raw_written_off_quantity" set default '{"value":"0","precision":20}';` |
|
53
|
) |
|
54
|
|
|
55
|
this.addSql( |
|
56
|
`alter table if exists "return_item" alter column "raw_received_quantity" type jsonb using ("raw_received_quantity"::jsonb);` |
|
57
|
) |
|
58
|
this.addSql( |
|
59
|
`alter table if exists "return_item" alter column "raw_received_quantity" set default '{"value":"0","precision":20}';` |
|
60
|
) |
|
61
|
this.addSql( |
|
62
|
`alter table if exists "return_item" alter column "raw_damaged_quantity" type jsonb using ("raw_damaged_quantity"::jsonb);` |
|
63
|
) |
|
64
|
this.addSql( |
|
65
|
`alter table if exists "return_item" alter column "raw_damaged_quantity" set default '{"value":"0","precision":20}';` |
|
66
|
) |
|
67
|
} |
|
68
|
|
|
69
|
override async down(): Promise<void> { |
|
70
|
this.addSql(`drop index if exists "IDX_order_custom_display_id";`) |
|
71
|
this.addSql( |
|
72
|
`alter table if exists "order" drop column if exists "custom_display_id";` |
|
73
|
) |
|
74
|
|
|
75
|
this.addSql( |
|
76
|
`alter table if exists "order_item" alter column "raw_fulfilled_quantity" drop default;` |
|
77
|
) |
|
78
|
this.addSql( |
|
79
|
`alter table if exists "order_item" alter column "raw_fulfilled_quantity" type jsonb using ("raw_fulfilled_quantity"::jsonb);` |
|
80
|
) |
|
81
|
this.addSql( |
|
82
|
`alter table if exists "order_item" alter column "raw_delivered_quantity" drop default;` |
|
83
|
) |
|
84
|
this.addSql( |
|
85
|
`alter table if exists "order_item" alter column "raw_delivered_quantity" type jsonb using ("raw_delivered_quantity"::jsonb);` |
|
86
|
) |
|
87
|
this.addSql( |
|
88
|
`alter table if exists "order_item" alter column "raw_shipped_quantity" drop default;` |
|
89
|
) |
|
90
|
this.addSql( |
|
91
|
`alter table if exists "order_item" alter column "raw_shipped_quantity" type jsonb using ("raw_shipped_quantity"::jsonb);` |
|
92
|
) |
|
93
|
this.addSql( |
|
94
|
`alter table if exists "order_item" alter column "raw_return_requested_quantity" drop default;` |
|
95
|
) |
|
96
|
this.addSql( |
|
97
|
`alter table if exists "order_item" alter column "raw_return_requested_quantity" type jsonb using ("raw_return_requested_quantity"::jsonb);` |
|
98
|
) |
|
99
|
this.addSql( |
|
100
|
`alter table if exists "order_item" alter column "raw_return_received_quantity" drop default;` |
|
101
|
) |
|
102
|
this.addSql( |
|
103
|
`alter table if exists "order_item" alter column "raw_return_received_quantity" type jsonb using ("raw_return_received_quantity"::jsonb);` |
|
104
|
) |
|
105
|
this.addSql( |
|
106
|
`alter table if exists "order_item" alter column "raw_return_dismissed_quantity" drop default;` |
|
107
|
) |
|
108
|
this.addSql( |
|
109
|
`alter table if exists "order_item" alter column "raw_return_dismissed_quantity" type jsonb using ("raw_return_dismissed_quantity"::jsonb);` |
|
110
|
) |
|
111
|
this.addSql( |
|
112
|
`alter table if exists "order_item" alter column "raw_written_off_quantity" drop default;` |
|
113
|
) |
|
114
|
this.addSql( |
|
115
|
`alter table if exists "order_item" alter column "raw_written_off_quantity" type jsonb using ("raw_written_off_quantity"::jsonb);` |
|
116
|
) |
|
117
|
|
|
118
|
this.addSql( |
|
119
|
`alter table if exists "return_item" alter column "raw_received_quantity" drop default;` |
|
120
|
) |
|
121
|
this.addSql( |
|
122
|
`alter table if exists "return_item" alter column "raw_received_quantity" type jsonb using ("raw_received_quantity"::jsonb);` |
|
123
|
) |
|
124
|
this.addSql( |
|
125
|
`alter table if exists "return_item" alter column "raw_damaged_quantity" drop default;` |
|
126
|
) |
|
127
|
this.addSql( |
|
128
|
`alter table if exists "return_item" alter column "raw_damaged_quantity" type jsonb using ("raw_damaged_quantity"::jsonb);` |
|
129
|
) |
|
130
|
} |
|
131
|
} |