fix(order): run migration before setting not null (#8831)

This commit is contained in:
Riqwan Thamir
2024-08-28 10:10:35 +02:00
committed by GitHub
parent 69c5d122b1
commit 2ee374fafc

View File

@@ -3,7 +3,15 @@ import { Migration } from "@mikro-orm/migrations"
export class Migration20240827133639 extends Migration {
async up(): Promise<void> {
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;'
)
}