Spaces:
Sleeping
Sleeping
import { MigrationInterface, QueryRunner } from "typeorm"; | |
export class AddBranchMenus1729703705445 implements MigrationInterface { | |
name = 'AddBranchMenus1729703705445' | |
public async up(queryRunner: QueryRunner): Promise<void> { | |
await queryRunner.query(`CREATE TABLE "menu_items" ("id" character varying NOT NULL, "item_name" character varying NOT NULL, "image_url" character varying, "item_group_id" character varying, "description" character varying NOT NULL, "price" integer NOT NULL, "create_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_57e6188f929e5dc6919168620c8" PRIMARY KEY ("id"))`); | |
await queryRunner.query(`CREATE TABLE "branch_menu" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "branch_id" character varying NOT NULL, "menu_id" character varying NOT NULL, "description" character varying NOT NULL, "is_open" boolean NOT NULL, "branchId" uuid, "menuItemId" character varying, CONSTRAINT "PK_977becffe98bbc626a56031b9e7" PRIMARY KEY ("id"))`); | |
await queryRunner.query(`ALTER TABLE "branch_menu" ADD CONSTRAINT "FK_e0c721a124fa03ea4cef6f28f42" FOREIGN KEY ("branchId") REFERENCES "branches"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); | |
await queryRunner.query(`ALTER TABLE "branch_menu" ADD CONSTRAINT "FK_cbfb42df5887653593974e3e285" FOREIGN KEY ("menuItemId") REFERENCES "menu_items"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); | |
} | |
public async down(queryRunner: QueryRunner): Promise<void> { | |
await queryRunner.query(`ALTER TABLE "branch_menu" DROP CONSTRAINT "FK_cbfb42df5887653593974e3e285"`); | |
await queryRunner.query(`ALTER TABLE "branch_menu" DROP CONSTRAINT "FK_e0c721a124fa03ea4cef6f28f42"`); | |
await queryRunner.query(`DROP TABLE "branch_menu"`); | |
await queryRunner.query(`DROP TABLE "menu_items"`); | |
} | |
} | |