import { MigrationInterface, QueryRunner } from 'typeorm'

export class RemoveSingleTableFromReservationAndOrder1729857492267 implements MigrationInterface {
	name = 'RemoveSingleTableFromReservationAndOrder1729857492267'

	public async up(queryRunner: QueryRunner): Promise<void> {
		await queryRunner.query(`ALTER TABLE "reservation" DROP CONSTRAINT "FK_d221f3398a0352970306b3dc676"`)
		await queryRunner.query(`ALTER TABLE "order" DROP CONSTRAINT "FK_a9757413db9333d4bb21a2a42aa"`)
		await queryRunner.query(`ALTER TABLE "reservation" DROP COLUMN "tableId"`)
		await queryRunner.query(`ALTER TABLE "order" DROP COLUMN "tableId"`)
	}

	public async down(queryRunner: QueryRunner): Promise<void> {
		await queryRunner.query(`ALTER TABLE "order" ADD "tableId" uuid`)
		await queryRunner.query(`ALTER TABLE "reservation" ADD "tableId" uuid`)
		await queryRunner.query(
			`ALTER TABLE "order" ADD CONSTRAINT "FK_a9757413db9333d4bb21a2a42aa" FOREIGN KEY ("tableId") REFERENCES "table"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
		)
		await queryRunner.query(
			`ALTER TABLE "reservation" ADD CONSTRAINT "FK_d221f3398a0352970306b3dc676" FOREIGN KEY ("tableId") REFERENCES "table"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
		)
	}
}
