diff --git a/packages/modules/order/src/migrations/Migration20240827133639.ts b/packages/modules/order/src/migrations/Migration20240827133639.ts index 979d56c359..a1587cac1f 100644 --- a/packages/modules/order/src/migrations/Migration20240827133639.ts +++ b/packages/modules/order/src/migrations/Migration20240827133639.ts @@ -3,7 +3,15 @@ import { Migration } from "@mikro-orm/migrations" export class Migration20240827133639 extends Migration { async up(): Promise { this.addSql( - 'alter table if exists "return_item" add column if not exists "damaged_quantity" numeric not null default 0, add column if not exists "raw_damaged_quantity" jsonb not null;' + 'alter table if exists "return_item" add column if not exists "damaged_quantity" numeric not null default 0, add column if not exists "raw_damaged_quantity" jsonb;' + ) + + this.addSql( + `UPDATE "return_item" SET raw_damaged_quantity = '{"value": "0", "precision": 20}'::jsonb;` + ) + + this.addSql( + 'ALTER TABLE IF EXISTS "return_item" ALTER COLUMN "raw_damaged_quantity" SET NOT NULL;' ) }