import { MigrationInterface, QueryRunner } from "typeorm";

export class Migrations1743592026149 implements MigrationInterface {
    name = 'Migrations1743592026149'

    public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`ALTER TYPE "public"."settings_type_enum" RENAME TO "settings_type_enum_old"`);
        await queryRunner.query(`CREATE TYPE "public"."settings_type_enum" AS ENUM('facebook_followers_count', 'instagram_followers_count', 'tiktok_followers_count', 'youtube_subscriber_count', 'category_min', 'category_max', 'industry_min', 'industry_max', 'platform_charge', 'job_category_score', 'platform_score', 'geography_score', 'currency_score', 'registered_influencer_score', 'influencer_job_category_score', 'influencer_platform_score', 'influencer_geography_score', 'influencer_currency_score', 'trending_follower_count', 'trending_engagement_count')`);
        await queryRunner.query(`ALTER TABLE "settings" ALTER COLUMN "type" DROP DEFAULT`);
        await queryRunner.query(`ALTER TABLE "settings" ALTER COLUMN "type" TYPE "public"."settings_type_enum" USING "type"::"text"::"public"."settings_type_enum"`);
        await queryRunner.query(`ALTER TABLE "settings" ALTER COLUMN "type" SET DEFAULT 'facebook_followers_count'`);
        await queryRunner.query(`DROP TYPE "public"."settings_type_enum_old"`);
    }

    public async down(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`CREATE TYPE "public"."settings_type_enum_old" AS ENUM('facebook_followers_count', 'instagram_followers_count', 'tiktok_followers_count', 'youtube_subscriber_count', 'category_min', 'category_max', 'industry_min', 'industry_max', 'platform_charge', 'job_category_score', 'platform_score', 'geography_score', 'currency_score', 'influencer_job_category_score', 'influencer_platform_score', 'influencer_geography_score', 'influencer_currency_score', 'trending_follower_count', 'trending_engagement_count')`);
        await queryRunner.query(`ALTER TABLE "settings" ALTER COLUMN "type" DROP DEFAULT`);
        await queryRunner.query(`ALTER TABLE "settings" ALTER COLUMN "type" TYPE "public"."settings_type_enum_old" USING "type"::"text"::"public"."settings_type_enum_old"`);
        await queryRunner.query(`ALTER TABLE "settings" ALTER COLUMN "type" SET DEFAULT 'facebook_followers_count'`);
        await queryRunner.query(`DROP TYPE "public"."settings_type_enum"`);
        await queryRunner.query(`ALTER TYPE "public"."settings_type_enum_old" RENAME TO "settings_type_enum"`);
    }

}
