import { MigrationInterface, QueryRunner } from "typeorm";

export class AddJobEntity1747414758524 implements MigrationInterface {
    name = 'AddJobEntity1747414758524'

    public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`CREATE TABLE \`jobs\` (\`id\` int NOT NULL AUTO_INCREMENT, \`title\` varchar(255) NOT NULL, \`department\` varchar(255) NOT NULL, \`location\` json NOT NULL, \`description\` text NOT NULL, \`content_sections\` json NULL, \`salary_range\` json NULL, \`slug\` varchar(255) NULL, \`posted_at\` timestamp NOT NULL, \`is_active\` tinyint NOT NULL DEFAULT 1, \`application_url\` varchar(255) NULL, \`created_at\` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), \`updated_at\` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
        await queryRunner.query(`ALTER TABLE \`monitored_websites\` CHANGE \`priority\` \`priority\` int(1) NOT NULL COMMENT 'Priority level (1=highest, 5=lowest)'`);
    }

    public async down(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`ALTER TABLE \`monitored_websites\` CHANGE \`priority\` \`priority\` int NOT NULL COMMENT 'Priority level (1=highest, 5=lowest)'`);
        await queryRunner.query(`DROP TABLE \`jobs\``);
    }

}
