import { MigrationInterface, QueryRunner } from 'typeorm'

export class AddMessageEntity1697533727979 implements MigrationInterface {
	name = 'AddMessageEntity1697533727979'

	public async up(queryRunner: QueryRunner): Promise<void> {
		await queryRunner.query(
			`CREATE TYPE "public"."message_type_enum" AS ENUM('order', 'request_payment', 'request_order', 'request_waiter', 'card_payment_complete', 'dish_ready_to_serve')`,
		)
		await queryRunner.query(
			`CREATE TABLE "message" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "tenantId" uuid, "createdBy" uuid, "lastUpdatedAt" TIMESTAMP NOT NULL DEFAULT now(), "lastUpdatedBy" uuid, "body" text NOT NULL, "type" "public"."message_type_enum" NOT NULL DEFAULT 'request_waiter', "acknowledged" boolean NOT NULL DEFAULT false, "acknowledgedAt" TIMESTAMP, "acknowledgedBy" uuid, "tableId" uuid NOT NULL, CONSTRAINT "PK_ba01f0a3e0123651915008bc578" PRIMARY KEY ("id"))`,
		)
	}

	public async down(queryRunner: QueryRunner): Promise<void> {
		await queryRunner.query(`DROP TABLE "message"`)
		await queryRunner.query(`DROP TYPE "public"."message_type_enum"`)
	}
}
