'use strict'; module.exports = { up: async (queryInterface, Sequelize) => { const { NODE_ENV } = process.env; // Get the current environment from NODE_ENV // Conditional logic based on environment if (NODE_ENV === 'development' || NODE_ENV === 'staging') { console.log(`Applying migrations for ${NODE_ENV} environment...`); await queryInterface.changeColumn('user_uploads', 'file_name', { type: Sequelize.TEXT, allowNull: false, // You can keep it as required, adjust as needed }); // Change the 'file_name' column to TEXT type await queryInterface.changeColumn('user_uploads', 'file_path', { type: Sequelize.TEXT, allowNull: false, // You can keep it as required, adjust as needed }); // Change the 'file_name' column to TEXT type await queryInterface.changeColumn('user_uploads', 'file_type', { type: Sequelize.TEXT, allowNull: false, // You can keep it as required, adjust as needed }); // Change the 'file_name' column to TEXT type await queryInterface.changeColumn('user_uploads', 'overall_metrics', { type: Sequelize.TEXT, allowNull: false, // You can keep it as required, adjust as needed }); // Change the 'file_name' column to TEXT type await queryInterface.changeColumn('user_uploads', 'backhand', { type: Sequelize.TEXT, allowNull: false, // You can keep it as required, adjust as needed }); await queryInterface.changeColumn('user_uploads', 'service', { type: Sequelize.TEXT, allowNull: false, // You can keep it as required, adjust as needed }); await queryInterface.changeColumn('user_uploads', 'smash', { type: Sequelize.TEXT, allowNull: false, // You can keep it as required, adjust as needed }); await queryInterface.changeColumn('user_uploads', 'forehand', { type: Sequelize.TEXT, allowNull: false, // You can keep it as required, adjust as needed }); // Add columns only for development or staging environments await queryInterface.addColumn('user_uploads', 'overall_metrics', { type: Sequelize.STRING, allowNull: true, }); await queryInterface.addColumn('user_uploads', 'backhand', { type: Sequelize.STRING, allowNull: true, }); await queryInterface.addColumn('user_uploads', 'forehand', { type: Sequelize.STRING, allowNull: true, }); await queryInterface.addColumn('user_uploads', 'service', { type: Sequelize.STRING, allowNull: true, }); await queryInterface.addColumn('user_uploads', 'smash', { type: Sequelize.STRING, allowNull: true, }); } // Optionally, you could apply the columns to the production environment as well: if (NODE_ENV === 'production') { console.log('Applying migrations for production environment...'); // You can add production-specific migration logic if needed here. // For now, it's the same as dev and staging await queryInterface.addColumn('user_uploads', 'overall_metrics', { type: Sequelize.STRING, allowNull: true, }); await queryInterface.addColumn('user_uploads', 'backhand', { type: Sequelize.STRING, allowNull: true, }); await queryInterface.addColumn('user_uploads', 'forehand', { type: Sequelize.STRING, allowNull: true, }); await queryInterface.addColumn('user_uploads', 'service', { type: Sequelize.STRING, allowNull: true, }); await queryInterface.addColumn('user_uploads', 'smash', { type: Sequelize.STRING, allowNull: true, }); } }, down: async (queryInterface, Sequelize) => { const { NODE_ENV } = process.env; // Get the current environment from NODE_ENV // Remove columns based on the environment if (NODE_ENV === 'development' || NODE_ENV === 'staging') { console.log(`Rolling back migrations for ${NODE_ENV} environment...`); await queryInterface.removeColumn('user_uploads', 'overall_metrics'); await queryInterface.removeColumn('user_uploads', 'backhand'); await queryInterface.removeColumn('user_uploads', 'forehand'); await queryInterface.removeColumn('user_uploads', 'service'); await queryInterface.removeColumn('user_uploads', 'smash'); } // Optionally, you could apply the rollback for production as well: if (NODE_ENV === 'production') { console.log('Rolling back migrations for production environment...'); await queryInterface.removeColumn('user_uploads', 'overall_metrics'); await queryInterface.removeColumn('user_uploads', 'backhand'); await queryInterface.removeColumn('user_uploads', 'forehand'); await queryInterface.removeColumn('user_uploads', 'service'); await queryInterface.removeColumn('user_uploads', 'smash'); } } };