import { MigrationInterface, QueryRunner } from "typeorm";

export class CheckContentAndAddSetting1753271148946 implements MigrationInterface {
    name = 'CheckContentAndAddSetting1753271148946'

    public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`CREATE TABLE \`user_settings\` (\`id\` int NOT NULL AUTO_INCREMENT, \`user_id\` int NOT NULL, \`key\` varchar(255) NOT NULL, \`value\` text NOT NULL, \`created_at\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), \`updated_at\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), UNIQUE INDEX \`IDX_2a7075951229168cb8d8c51237\` (\`user_id\`, \`key\`), PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
        await queryRunner.query(`CREATE TABLE \`app_settings\` (\`id\` int NOT NULL AUTO_INCREMENT, \`key\` varchar(255) NOT NULL, \`value\` text NOT NULL, \`created_at\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), \`updated_at\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), UNIQUE INDEX \`IDX_975c2db59c65c05fd9c6b63a2a\` (\`key\`), PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
        await queryRunner.query(`ALTER TABLE \`breach_check_websites\` ADD \`check_content_with_ai\` tinyint NOT NULL DEFAULT 0`);
    }

    public async down(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`ALTER TABLE \`breach_check_websites\` DROP COLUMN \`check_content_with_ai\``);
        await queryRunner.query(`DROP INDEX \`IDX_975c2db59c65c05fd9c6b63a2a\` ON \`app_settings\``);
        await queryRunner.query(`DROP TABLE \`app_settings\``);
        await queryRunner.query(`DROP INDEX \`IDX_2a7075951229168cb8d8c51237\` ON \`user_settings\``);
        await queryRunner.query(`DROP TABLE \`user_settings\``);
    }

}
