This commit is contained in:
@@ -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");`);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user