import { MigrationInterface, QueryRunner } from 'typeorm';

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

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `CREATE TYPE "public"."season_periods_status_enum" AS ENUM('active', 'cancel', 'confirmed', 'draft', 'expired', 'inactive', 'pending', 'refunded', 'rejected', 'settled', 'waiting')`,
    );
    await queryRunner.query(
      `CREATE TABLE "season_periods" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "creator_id" character varying(36), "creator_name" character varying(125), "editor_id" character varying(36), "editor_name" character varying(125), "created_at" bigint NOT NULL, "updated_at" bigint NOT NULL, "status" "public"."season_periods_status_enum" NOT NULL DEFAULT 'draft', "start_date" date, "end_date" date, "days" text, "holiday_name" character varying, "season_type_id" uuid, CONSTRAINT "PK_8e25cedd8ffb18516de871fb4e0" PRIMARY KEY ("id"))`,
    );
    await queryRunner.query(
      `ALTER TABLE "season_periods" ADD CONSTRAINT "FK_4e9e71a640b450d23177c2add46" FOREIGN KEY ("season_type_id") REFERENCES "season_types"("id") ON DELETE CASCADE ON UPDATE CASCADE`,
    );
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `ALTER TABLE "season_periods" DROP CONSTRAINT "FK_4e9e71a640b450d23177c2add46"`,
    );
    await queryRunner.query(`DROP TABLE "season_periods"`);
    await queryRunner.query(`DROP TYPE "public"."season_periods_status_enum"`);
  }
}
