"use strict";

module.exports = {
  up: async (queryInterface, Sequelize) => {
    // Add bankDepositStatus enum column
    await queryInterface.addColumn("Rentals", "bankDepositStatus", {
      type: Sequelize.ENUM("pending", "in_transit", "paid", "failed", "canceled"),
      allowNull: true,
      defaultValue: null,
    });

    // Add bankDepositAt timestamp
    await queryInterface.addColumn("Rentals", "bankDepositAt", {
      type: Sequelize.DATE,
      allowNull: true,
    });

    // Add stripePayoutId to track which Stripe payout included this transfer
    await queryInterface.addColumn("Rentals", "stripePayoutId", {
      type: Sequelize.STRING,
      allowNull: true,
    });

    // Add bankDepositFailureCode for failed deposits
    await queryInterface.addColumn("Rentals", "bankDepositFailureCode", {
      type: Sequelize.STRING,
      allowNull: true,
    });
  },

  down: async (queryInterface, Sequelize) => {
    await queryInterface.removeColumn("Rentals", "bankDepositFailureCode");
    await queryInterface.removeColumn("Rentals", "stripePayoutId");
    await queryInterface.removeColumn("Rentals", "bankDepositAt");
    await queryInterface.removeColumn("Rentals", "bankDepositStatus");

    // Drop the enum type (PostgreSQL specific)
    await queryInterface.sequelize.query(
      'DROP TYPE IF EXISTS "enum_Rentals_bankDepositStatus";'
    );
  },
};
