29 lines
1.7 KiB
TypeScript
29 lines
1.7 KiB
TypeScript
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);`);
|
|
}
|
|
}
|