fix review table migration
deploy to danak / build_and_deploy (push) Has been cancelled

This commit is contained in:
2026-07-15 12:39:53 +03:30
parent 204b4f2007
commit 4abc2ae6e5
2 changed files with 19 additions and 0 deletions
@@ -0,0 +1,17 @@
import { Migration } from '@mikro-orm/migrations';
export class Migration20260715120000_dropReviewsOrderId extends Migration {
override async up(): Promise<void> {
this.addSql(`alter table "reviews" drop column if exists "order_id";`);
}
override async down(): Promise<void> {
this.addSql(`alter table "reviews" add column "order_id" char(26) not null;`);
this.addSql(`alter table "reviews" add constraint "reviews_order_id_foreign" foreign key ("order_id") references "orders" ("id") on update cascade;`);
this.addSql(`create index "reviews_order_id_index" on "reviews" ("order_id");`);
this.addSql(`alter table "reviews" drop constraint if exists "reviews_food_id_user_id_unique";`);
this.addSql(`alter table "reviews" add constraint "reviews_order_id_food_id_user_id_unique" unique ("order_id", "food_id", "user_id");`);
}
}