import { MigrationInterface, QueryRunner } from 'typeorm';

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

  public async up(queryRunner: QueryRunner): Promise<void> {
    // Create uuid-ossp extension for uuid_generate_v4() function
    await queryRunner.query(`CREATE EXTENSION IF NOT EXISTS "uuid-ossp"`);
    await queryRunner.query(
      `CREATE TYPE "public"."ideas_status_enum" AS ENUM('backlog', 'todo', 'in_progress', 'done', 'cancelled')`,
    );
    await queryRunner.query(
      `CREATE TYPE "public"."ideas_priority_enum" AS ENUM('low', 'medium', 'high', 'critical')`,
    );
    await queryRunner.query(`
      CREATE TABLE "ideas" (
        "id" uuid NOT NULL DEFAULT uuid_generate_v4(),
        "title" character varying NOT NULL,
        "description" text,
        "status" "public"."ideas_status_enum" NOT NULL DEFAULT 'backlog',
        "priority" "public"."ideas_priority_enum" NOT NULL DEFAULT 'medium',
        "module" character varying(100),
        "target_audience" character varying(255),
        "pain" text,
        "ai_role" text,
        "verification_method" text,
        "color" character varying(20),
        "order" integer NOT NULL DEFAULT '0',
        "created_at" TIMESTAMP NOT NULL DEFAULT now(),
        "updated_at" TIMESTAMP NOT NULL DEFAULT now(),
        CONSTRAINT "PK_ideas_id" PRIMARY KEY ("id")
      )
    `);
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`DROP TABLE "ideas"`);
    await queryRunner.query(`DROP TYPE "public"."ideas_priority_enum"`);
    await queryRunner.query(`DROP TYPE "public"."ideas_status_enum"`);
  }
}
