import { MigrationInterface, QueryRunner } from 'typeorm'

export class AddTableEntity1696416031123 implements MigrationInterface {
	name = 'AddTableEntity1696416031123'

	public async up(queryRunner: QueryRunner): Promise<void> {
		await queryRunner.query(`CREATE TYPE "public"."table_shape_enum" AS ENUM('rectangle', 'round')`)
		await queryRunner.query(
			`CREATE TABLE "table" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "deletedAt" TIMESTAMP, "name" character varying(30) NOT NULL, "capacity" integer NOT NULL, "width" integer NOT NULL, "height" integer NOT NULL, "columnStart" integer NOT NULL, "rowStart" integer NOT NULL, "shape" "public"."table_shape_enum" NOT NULL DEFAULT 'rectangle', CONSTRAINT "PK_28914b55c485fc2d7a101b1b2a4" PRIMARY KEY ("id"))`,
		)
		await queryRunner.query(`ALTER TABLE "menu_item_category" DROP COLUMN "deletedAt"`)
	}

	public async down(queryRunner: QueryRunner): Promise<void> {
		await queryRunner.query(`ALTER TABLE "menu_item_category" ADD "deletedAt" TIMESTAMP`)
		await queryRunner.query(`DROP TABLE "table"`)
		await queryRunner.query(`DROP TYPE "public"."table_shape_enum"`)
	}
}
