/**
 * 更新操作日志表操作类型枚举
 * @file 20250118000011_update_operation_logs_enum.js
 * @description 添加更多操作类型到操作日志表
 */
'use strict';

module.exports = {
  async up(queryInterface, Sequelize) {
    try {
      console.log('开始更新操作日志表操作类型枚举...');
      
      // 修改操作类型枚举
      await queryInterface.changeColumn('operation_logs', 'operation_type', {
        type: Sequelize.ENUM(
          'CREATE', 
          'UPDATE', 
          'DELETE', 
          'READ', 
          'LOGIN', 
          'LOGOUT', 
          'EXPORT', 
          'IMPORT', 
          'BATCH_DELETE', 
          'BATCH_UPDATE'
        ),
        allowNull: false,
        comment: '操作类型：CREATE-新增，UPDATE-编辑，DELETE-删除，READ-查看，LOGIN-登录，LOGOUT-登出，EXPORT-导出，IMPORT-导入，BATCH_DELETE-批量删除，BATCH_UPDATE-批量更新'
      });
      
      console.log('✅ 操作日志表操作类型枚举更新成功');
    } catch (error) {
      console.error('❌ 更新操作日志表操作类型枚举失败:', error);
      throw error;
    }
  },

  async down(queryInterface, Sequelize) {
    try {
      console.log('开始回滚操作日志表操作类型枚举...');
      
      // 回滚到原始枚举
      await queryInterface.changeColumn('operation_logs', 'operation_type', {
        type: Sequelize.ENUM('CREATE', 'UPDATE', 'DELETE'),
        allowNull: false,
        comment: '操作类型：CREATE-新增，UPDATE-编辑，DELETE-删除'
      });
      
      console.log('✅ 操作日志表操作类型枚举回滚成功');
    } catch (error) {
      console.error('❌ 回滚操作日志表操作类型枚举失败:', error);
      throw error;
    }
  }
};
