import { MigrationInterface, QueryRunner } from "typeorm";

export class ScanResult1742913912722 implements MigrationInterface {
    name = 'ScanResult1742913912722'

    public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`CREATE TABLE \`website_scan_results\` (\`id\` int NOT NULL AUTO_INCREMENT, \`website_url\` varchar(255) NOT NULL, \`scan_status\` enum ('in-progress', 'completed', 'failed') NOT NULL DEFAULT 'in-progress', \`scan_results\` json NULL, \`error_message\` varchar(255) NULL, \`scan_date\` datetime 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), PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
        await queryRunner.query(`CREATE INDEX \`IDX_35f7274b5aa5e55b4ad7f734b7\` ON \`city_block_ipv4\` (\`network\`)`);
        await queryRunner.query(`CREATE INDEX \`IDX_8fa451946cbfc66d1494b055e8\` ON \`city_block_ipv6\` (\`network\`)`);
    }

    public async down(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`DROP INDEX \`IDX_8fa451946cbfc66d1494b055e8\` ON \`city_block_ipv6\``);
        await queryRunner.query(`DROP INDEX \`IDX_35f7274b5aa5e55b4ad7f734b7\` ON \`city_block_ipv4\``);
        await queryRunner.query(`DROP TABLE \`website_scan_results\``);
    }

}
