import { MigrationInterface, QueryRunner } from "typeorm";

export class Migrations1754994048425 implements MigrationInterface {
    name = 'Migrations1754994048425'

    public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`CREATE TYPE "public"."error_reports_platform_enum" AS ENUM('facebook', 'instagram', 'youtube', 'tiktok')`);
        await queryRunner.query(`CREATE TABLE "error_reports" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "platform" "public"."error_reports_platform_enum" NOT NULL, "handle" character varying(80) NOT NULL, "description" text NOT NULL, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "usersId" uuid, CONSTRAINT "PK_7ad997b17e029b745874a1a1eac" PRIMARY KEY ("id"))`);
        await queryRunner.query(`ALTER TABLE "error_reports" ADD CONSTRAINT "FK_be871774b07a0c4b4ddafb744a0" FOREIGN KEY ("usersId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
    }

    public async down(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`ALTER TABLE "error_reports" DROP CONSTRAINT "FK_be871774b07a0c4b4ddafb744a0"`);
        await queryRunner.query(`DROP TABLE "error_reports"`);
        await queryRunner.query(`DROP TYPE "public"."error_reports_platform_enum"`);
    }

}
