"use strict";

module.exports = {
  up: async (queryInterface, Sequelize) => {
    // Add twoFaEnabled to Admins
    await queryInterface.addColumn("Admins", "twoFaEnabled", {
      type: Sequelize.BOOLEAN,
      defaultValue: false,
      allowNull: false,
    });

    // Add twoFaEnabled, passwordResetToken, passwordResetExpires to Merchants
    await queryInterface.addColumn("Merchants", "twoFaEnabled", {
      type: Sequelize.BOOLEAN,
      defaultValue: false,
      allowNull: false,
    });
    await queryInterface.addColumn("Merchants", "passwordResetToken", {
      type: Sequelize.STRING,
      allowNull: true,
    });
    await queryInterface.addColumn("Merchants", "passwordResetExpires", {
      type: Sequelize.DATE,
      allowNull: true,
    });

    // Add passwordResetToken and passwordResetExpires to Admins as well
    await queryInterface.addColumn("Admins", "passwordResetToken", {
      type: Sequelize.STRING,
      allowNull: true,
    });
    await queryInterface.addColumn("Admins", "passwordResetExpires", {
      type: Sequelize.DATE,
      allowNull: true,
    });
  },

  down: async (queryInterface, Sequelize) => {
    await queryInterface.removeColumn("Admins", "twoFaEnabled");
    await queryInterface.removeColumn("Admins", "passwordResetToken");
    await queryInterface.removeColumn("Admins", "passwordResetExpires");
    await queryInterface.removeColumn("Merchants", "twoFaEnabled");
    await queryInterface.removeColumn("Merchants", "passwordResetToken");
    await queryInterface.removeColumn("Merchants", "passwordResetExpires");
  },
};
