24 lines
1.5 KiB
TypeScript
24 lines
1.5 KiB
TypeScript
import { Migration } from '@mikro-orm/migrations';
|
|
|
|
export class Migration20260628071208 extends Migration {
|
|
|
|
override async up(): Promise<void> {
|
|
this.addSql(`alter table "orders" drop constraint if exists "orders_status_check";`);
|
|
|
|
this.addSql(`alter table "products" add column "min_purchase_quantity" int null, add column "pricing_type" text check ("pricing_type" in ('fixed', 'variable')) not null default 'fixed', add column "purchase_unit" text check ("purchase_unit" in ('number', 'kilogram', 'gram', 'centimeter', 'meter', 'milliliter', 'liter')) not null default 'number', add column "purchase_pitch" numeric(10,3) null, add column "need_admin_acceptance" boolean not null default false;`);
|
|
|
|
this.addSql(`alter table "orders" add constraint "orders_status_check" check("status" in ('pendingPayment', 'paid', 'preparing', 'deliveredToRecepient', 'shipped', 'completed', 'canceled', 'needConfirmation'));`);
|
|
|
|
this.addSql(`alter table "order_items" add column "status" text check ("status" in ('normal', 'needConfirmation', 'confirmed')) not null default 'normal';`);
|
|
}
|
|
|
|
override async down(): Promise<void> {
|
|
this.addSql(`alter table "orders" drop constraint if exists "orders_status_check";`);
|
|
|
|
this.addSql(`alter table "products" add column "price" numeric(10,0) null;`);
|
|
|
|
this.addSql(`alter table "orders" add constraint "orders_status_check" check("status" in ('pendingPayment', 'paid', 'preparing', 'deliveredToRecepient', 'shipped', 'completed', 'canceled'));`);
|
|
}
|
|
|
|
}
|