'use strict';

/**
 * Remove project.phase column - it's redundant.
 * Runtime access is controlled by tour_pages.environment, not project.phase.
 */
module.exports = {
  async up(queryInterface, _Sequelize) {
    // Drop the phase column
    await queryInterface.removeColumn('projects', 'phase');

    // Drop the ENUM type
    await queryInterface.sequelize.query(
      `DROP TYPE IF EXISTS "enum_projects_phase";`,
    );
  },

  async down(queryInterface, Sequelize) {
    // Recreate the ENUM type
    await queryInterface.sequelize.query(`
      CREATE TYPE "enum_projects_phase" AS ENUM ('dev', 'stage', 'production');
    `);

    // Recreate the column with default 'dev'
    await queryInterface.addColumn('projects', 'phase', {
      type: Sequelize.ENUM('dev', 'stage', 'production'),
      allowNull: false,
      defaultValue: 'dev',
    });
  },
};
