add: migration

This commit is contained in:
2026-02-17 16:04:49 +03:30
parent 2555cc12d1
commit 7ccf822a5c
18 changed files with 790 additions and 74 deletions
@@ -0,0 +1,28 @@
import { Migration } from "@mikro-orm/migrations";
export class Migration20260217122512_meterageREquired extends Migration {
override async up(): Promise<void> {
this.addSql(`alter table "company" alter column "metrage" type int using ("metrage"::int);`);
this.addSql(`update "company" set "metrage" = 0 where "metrage" is null;`);
this.addSql(`alter table "company" alter column "metrage" set not null;`);
this.addSql(`alter table "invoice" alter column "total_price" type numeric using ("total_price"::numeric);`);
this.addSql(`alter table "invoice" alter column "original_price" type numeric using ("original_price"::numeric);`);
this.addSql(`alter table "invoice" alter column "tax" type numeric using ("tax"::numeric);`);
this.addSql(`alter table "invoice" alter column "late_fee" type numeric using ("late_fee"::numeric);`);
this.addSql(`alter table "payment" alter column "amount" type numeric using ("amount"::numeric);`);
}
override async down(): Promise<void> {
this.addSql(`alter table "company" alter column "metrage" type int4 using ("metrage"::int4);`);
this.addSql(`alter table "company" alter column "metrage" drop not null;`);
this.addSql(`alter table "invoice" alter column "total_price" type numeric using ("total_price"::numeric);`);
this.addSql(`alter table "invoice" alter column "original_price" type numeric using ("original_price"::numeric);`);
this.addSql(`alter table "invoice" alter column "tax" type numeric using ("tax"::numeric);`);
this.addSql(`alter table "invoice" alter column "late_fee" type numeric using ("late_fee"::numeric);`);
this.addSql(`alter table "payment" alter column "amount" type numeric using ("amount"::numeric);`);
}
}