'use strict';

/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up(queryInterface, Sequelize) {
    await queryInterface.addColumn('payout_methods', 'bank_account_name', {
      type: Sequelize.STRING,
      allowNull: true,
    });
    await queryInterface.addColumn('payout_methods', 'bank_account_number', {
      type: Sequelize.STRING,
      allowNull: true,
    });
    await queryInterface.removeColumn('payout_methods', 'user_id');

    await queryInterface.addColumn('payout_methods', 'host_id', {
      type: Sequelize.UUID,
      references: {
        model: 'users',
        key: 'id',
      },
      allowNull: true,
    });
    await queryInterface.changeColumn('payout_methods', 'type', {
      type: Sequelize.STRING,
      allowNull: true,
    });
    await queryInterface.changeColumn('payout_methods', 'name', {
      type: Sequelize.STRING,
      allowNull: true,
    });
  },

  async down(queryInterface, Sequelize) {
    await queryInterface.removeColumn('payout_methods', 'bank_account_name');
    await queryInterface.removeColumn('payout_methods', 'bank_account_number');

    await queryInterface.removeColumn('payout_methods', 'host_id');
    await queryInterface.addColumn('payout_methods', 'user_id', {
      type: Sequelize.INTEGER,
      allowNull: true,
    });
    await queryInterface.changeColumn('payout_methods', 'type', {
      type: Sequelize.STRING,
      allowNull: false,
    });
    await queryInterface.changeColumn('payout_methods', 'name', {
      type: Sequelize.STRING,
      allowNull: false,
    });
  },
};
