Files
negareh-api/database/migrations/Migration20260221130421.ts
T
2026-02-21 16:35:45 +03:30

21 lines
1.0 KiB
TypeScript

import { Migration } from '@mikro-orm/migrations';
export class Migration20260221130421 extends Migration {
override async up(): Promise<void> {
this.addSql(`alter table "orders" drop constraint "orders_type_id_foreign";`);
this.addSql(`alter table "orders" add column "printery" varchar(255) null, add column "lithography" varchar(255) null;`);
this.addSql(`alter table "orders" add constraint "orders_type_id_foreign" foreign key ("type_id") references "categories" ("id") on update cascade;`);
}
override async down(): Promise<void> {
this.addSql(`create table "order_types" ("id" char(26) not null, "created_at" timestamptz not null default now(), "deleted_at" timestamptz null, "title" varchar(255) not null, constraint "order_types_pkey" primary key ("id"));`);
this.addSql(`alter table "orders" drop constraint "orders_type_id_foreign";`);
this.addSql(`alter table "orders" add constraint "orders_type_id_foreign" foreign key ("type_id") references "order_types" ("id") on update cascade;`);
}
}