'use strict';

/**
 * Migration: Add dual currency balance support
 * - Add balance_peso field to user table
 * - Add currency field to commissions table
 * - Add currency field to withdrawal table
 */

module.exports = {
  up: async (queryInterface, Sequelize) => {
    // Add balance_peso to user table
    await queryInterface.addColumn('user', 'balance_peso', {
      type: Sequelize.DECIMAL(10, 2),
      defaultValue: 0.00,
      allowNull: false,
      comment: '比索余额',
    });

    // Add currency to commissions table
    await queryInterface.addColumn('commissions', 'currency', {
      type: Sequelize.ENUM('RMB', 'PHP'),
      defaultValue: 'RMB',
      allowNull: false,
      comment: '佣金货币类型',
    });

    // Add currency to withdrawal table
    await queryInterface.addColumn('withdrawal', 'currency', {
      type: Sequelize.ENUM('CNY', 'PHP'),
      defaultValue: 'CNY',
      allowNull: false,
      comment: '提现货币类型',
    });
  },

  down: async (queryInterface, Sequelize) => {
    await queryInterface.removeColumn('user', 'balance_peso');
    await queryInterface.removeColumn('commissions', 'currency');
    await queryInterface.removeColumn('withdrawal', 'currency');
  },
};
