'use strict';
/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up(queryInterface, Sequelize) {
    await queryInterface.addColumn('invoices', 'skipped_at', {
      type: Sequelize.DATE,
      allowNull: true,
      defaultValue: null
    });
    await queryInterface.addColumn('invoices', 'skip_reason', {
      type: Sequelize.ENUM('auto_expired', 'manual', 'phone_error'),
      allowNull: true,
      defaultValue: null
    });
    await queryInterface.addColumn('invoices', 'skipped_by', {
      type: Sequelize.STRING,
      allowNull: true,
      defaultValue: null
    });
  },

  async down(queryInterface, Sequelize) {
    await queryInterface.removeColumn('invoices', 'skipped_at');
    await queryInterface.removeColumn('invoices', 'skip_reason');
    await queryInterface.removeColumn('invoices', 'skipped_by');
    // Drop ENUM type for MySQL/MariaDB
    await queryInterface.sequelize.query("ALTER TABLE `invoices` MODIFY COLUMN `skip_reason` VARCHAR(255) NULL;");
  }
};
