"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AddOnboardingPlanStages1784534500000 = void 0;
class AddOnboardingPlanStages1784534500000 {
    constructor() {
        this.name = "AddOnboardingPlanStages1784534500000";
    }
    async up(queryRunner) {
        await queryRunner.query(`
      CREATE TABLE IF NOT EXISTS \`onboarding_plan_stages\` (
        \`id\` varchar(36) NOT NULL,
        \`plan_id\` varchar(191) NOT NULL,
        \`name\` varchar(191) NOT NULL,
        \`sort_order\` int NOT NULL DEFAULT '0',
        \`created_at\` datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
        \`updated_at\` datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
        INDEX \`IDX_onboarding_plan_stages_plan\` (\`plan_id\`),
        PRIMARY KEY (\`id\`)
      ) ENGINE=InnoDB;
    `);
        const columns = await queryRunner.query(`
      SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS 
      WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'onboarding_plan_tasks' AND COLUMN_NAME = 'stage_id'
    `);
        if (!columns || columns.length === 0) {
            await queryRunner.query(`
        ALTER TABLE \`onboarding_plan_tasks\` ADD COLUMN \`stage_id\` varchar(191) NULL;
      `);
            await queryRunner.query(`
        ALTER TABLE \`onboarding_plan_tasks\` ADD INDEX \`IDX_onboarding_plan_tasks_stage\` (\`stage_id\`);
      `);
        }
    }
    async down(queryRunner) {
        await queryRunner.query(`DROP TABLE IF EXISTS \`onboarding_plan_stages\``);
    }
}
exports.AddOnboardingPlanStages1784534500000 = AddOnboardingPlanStages1784534500000;
//# sourceMappingURL=1784534500000-AddOnboardingPlanStages.js.map