'use strict';

module.exports = {
  async up(queryInterface, Sequelize) {
    await queryInterface.addColumn('Customers', 'tier', {
      type: Sequelize.ENUM('bronze', 'silver', 'gold', 'platinum'),
      allowNull: false,
      defaultValue: 'bronze'
    });

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

    await queryInterface.addColumn('Customers', 'nextTierThreshold', {
      type: Sequelize.DECIMAL(10, 2),
      allowNull: true
    });
  },

  async down(queryInterface, Sequelize) {
    await queryInterface.removeColumn('Customers', 'tier');
    await queryInterface.removeColumn('Customers', 'tierUpdatedAt');
    await queryInterface.removeColumn('Customers', 'nextTierThreshold');

    // Required cleanup for ENUM (Postgres/MySQL safe)
    await queryInterface.sequelize.query(
      'DROP TYPE IF EXISTS "enum_Customers_tier";'
    );
  }
};
