'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    await queryInterface.createTable('SystemServices', {
      id: {
        allowNull: false,
        primaryKey: true,
        type: Sequelize.UUID,
        defaultValue: Sequelize.UUIDV4
      },
      name: {
        type: Sequelize.STRING,
        allowNull: false
      },
      code: {
        type: Sequelize.STRING,
        allowNull: false,
        unique: true
      },
      currency: {
        type: Sequelize.STRING(10),
        allowNull: true
      },
      type: {
        type: Sequelize.STRING(30),
        allowNull: false,
        defaultValue: 'global_based'
      },
      description: {
        type: Sequelize.TEXT,
        allowNull: true
      },
      isActive: {
        type: Sequelize.BOOLEAN,
        defaultValue: true,
        allowNull: false
      },
      canReceive: {
        type: Sequelize.BOOLEAN,
        defaultValue: true,
        allowNull: false
      },
      canSend: {
        type: Sequelize.BOOLEAN,
        defaultValue: true,
        allowNull: false
      },
      createdAt: {
        allowNull: false,
        type: Sequelize.DATE
      },
      updatedAt: {
        allowNull: false,
        type: Sequelize.DATE
      }
    });

    await queryInterface.addIndex('SystemServices', ['code']);
    await queryInterface.addIndex('SystemServices', ['currency']);
  },

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