'use strict';

module.exports = {
  async up(queryInterface, Sequelize) {
    // Check if column already exists
    const tableDescription = await queryInterface.describeTable('build_cleanup_config');
    if (tableDescription.track_manual_sessions_in_builds) {
      console.log('Column "track_manual_sessions_in_builds" already exists, skipping migration');
      return;
    }

    // Add the column
    await queryInterface.addColumn('build_cleanup_config', 'track_manual_sessions_in_builds', {
      type: Sequelize.BOOLEAN,
      defaultValue: false,
      allowNull: false,
      comment: 'Whether manual device sessions should create build entries for tracking',
    });
  },

  async down(queryInterface, Sequelize) {
    await queryInterface.removeColumn('build_cleanup_config', 'track_manual_sessions_in_builds');
  },
};
