import { MigrationInterface, QueryRunner } from 'typeorm';

export class AddTableLogUserLogin1726123955427 implements MigrationInterface {
  name = 'AddTableLogUserLogin1726123955427';

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `CREATE TYPE "public"."log_users_login_type_enum" AS ENUM('login', 'logout')`,
    );
    await queryRunner.query(
      `CREATE TYPE "public"."log_users_login_role_enum" AS ENUM('superadmin', 'staff', 'tenant', 'queue_admin')`,
    );
    await queryRunner.query(
      `CREATE TABLE "log_users_login" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "type" "public"."log_users_login_type_enum", "role" "public"."log_users_login_role_enum", "user_id" uuid, "username" character varying, "created_at" bigint, CONSTRAINT "PK_75141588aa6ee560504f7d3adce" PRIMARY KEY ("id"))`,
    );
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`DROP TABLE "log_users_login"`);
    await queryRunner.query(`DROP TYPE "public"."log_users_login_role_enum"`);
    await queryRunner.query(`DROP TYPE "public"."log_users_login_type_enum"`);
  }
}
