Raw
1 import { Migration } from "@medusajs/framework/mikro-orm/migrations"
2
3 export class Migration20240913092514 extends Migration {
4 async up(): Promise<void> {
5 this.addSql(
6 'alter table if exists "order_item" add column if not exists "delivered_quantity" numeric not null default 0, add column if not exists "raw_delivered_quantity" jsonb;'
7 )
8
9 this.addSql(
10 `UPDATE "order_item" SET raw_delivered_quantity = '{"value": "0", "precision": 20}'::jsonb;`
11 )
12
13 this.addSql(
14 'ALTER TABLE IF EXISTS "order_item" ALTER COLUMN "raw_delivered_quantity" SET NOT NULL;'
15 )
16 }
17
18 async down(): Promise<void> {
19 this.addSql(
20 'alter table if exists "order_item" drop column if exists "delivered_quantity";'
21 )
22 this.addSql(
23 'alter table if exists "order_item" drop column if exists "raw_delivered_quantity";'
24 )
25 }
26 }