'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    await queryInterface.addColumn('Customers', 'bvn', {
      type: Sequelize.STRING,
      allowNull: true
    });

    await queryInterface.addColumn('Customers', 'bvnStatus', {
      type: Sequelize.ENUM('none', 'pending', 'verified', 'failed'),
      defaultValue: 'none',
      allowNull: false
    });

    await queryInterface.addColumn('Customers', 'idType', {
      type: Sequelize.STRING,
      allowNull: true
    });

    await queryInterface.addColumn('Customers', 'idValue', {
      type: Sequelize.STRING,
      allowNull: true
    });

    await queryInterface.addColumn('Customers', 'idStatus', {
      type: Sequelize.ENUM('none', 'pending', 'verified', 'failed'),
      defaultValue: 'none',
      allowNull: false
    });

    await queryInterface.addColumn('Customers', 'kycStatus', {
      type: Sequelize.ENUM('none', 'pending', 'verified', 'failed'),
      defaultValue: 'none',
      allowNull: false
    });
  },

  down: async (queryInterface, Sequelize) => {
    await queryInterface.removeColumn('Customers', 'kycStatus');
    await queryInterface.removeColumn('Customers', 'idStatus');
    await queryInterface.removeColumn('Customers', 'idValue');
    await queryInterface.removeColumn('Customers', 'idType');
    await queryInterface.removeColumn('Customers', 'bvnStatus');
    await queryInterface.removeColumn('Customers', 'bvn');

    // Drop ENUM types for postgres if applicable (though we can just use sequelize.query or let dropTable handle it, but for compatibility)
    await queryInterface.sequelize.query('DROP TYPE IF EXISTS "enum_Customers_bvnStatus";').catch(() => {});
    await queryInterface.sequelize.query('DROP TYPE IF EXISTS "enum_Customers_idStatus";').catch(() => {});
    await queryInterface.sequelize.query('DROP TYPE IF EXISTS "enum_Customers_kycStatus";').catch(() => {});
  }
};
