'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    await queryInterface.createTable('ServicePricings', {
      id: {
        type: Sequelize.UUID,
        defaultValue: Sequelize.UUIDV4,
        primaryKey: true,
        allowNull: false
      },
      serviceName: {
        type: Sequelize.STRING(50),
        allowNull: false
      },
      currency: {
        type: Sequelize.STRING(10),
        allowNull: false
      },
      providerPercentage: {
        type: Sequelize.DECIMAL(5, 4),
        defaultValue: 0.0000
      },
      providerFixedFee: {
        type: Sequelize.DECIMAL(15, 2),
        defaultValue: 0.00
      },
      providerMinCap: {
        type: Sequelize.DECIMAL(15, 2),
        defaultValue: 0.00
      },
      providerMaxCap: {
        type: Sequelize.DECIMAL(15, 2),
        defaultValue: 999999999.99
      },
      customerPercentage: {
        type: Sequelize.DECIMAL(5, 4),
        defaultValue: 0.0000
      },
      customerFixedFee: {
        type: Sequelize.DECIMAL(15, 2),
        defaultValue: 0.00
      },
      customerMinCap: {
        type: Sequelize.DECIMAL(15, 2),
        defaultValue: 0.00
      },
      customerMaxCap: {
        type: Sequelize.DECIMAL(15, 2),
        defaultValue: 999999999.99
      },
      isActive: {
        type: Sequelize.BOOLEAN,
        defaultValue: true
      },
      createdAt: {
        allowNull: false,
        type: Sequelize.DATE
      },
      updatedAt: {
        allowNull: false,
        type: Sequelize.DATE
      }
    });

    await queryInterface.addIndex('ServicePricings', ['serviceName', 'currency'], {
      name: 'service_pricings_name_currency_idx'
    });
  },

  down: async (queryInterface, Sequelize) => {
    await queryInterface.dropTable('ServicePricings');
  }
};
