"use strict";

module.exports = {
  up: async (queryInterface, Sequelize) => {
    await queryInterface.createTable("Settings", {
      id: {
        allowNull: false,
        autoIncrement: true,
        primaryKey: true,
        type: Sequelize.INTEGER,
      },
      key: {
        type: Sequelize.STRING,
        allowNull: false,
        unique: true,
      },
      value: {
        type: Sequelize.STRING,
        allowNull: false,
      },
      description: {
        type: Sequelize.TEXT,
        allowNull: true,
      },
      createdAt: {
        allowNull: false,
        type: Sequelize.DATE,
      },
      updatedAt: {
        allowNull: false,
        type: Sequelize.DATE,
      },
    });

    // Seed default settings
    await queryInterface.bulkInsert("Settings", [
      {
        key: "deposit_fee_percent",
        value: "0.5",
        description: "Default deposit fee percentage (e.g., 0.5 for 0.5%)",
        createdAt: new Date(),
        updatedAt: new Date(),
      },
      {
        key: "deposit_fee_cap",
        value: "100",
        description: "Default maximum fee for a single deposit",
        createdAt: new Date(),
        updatedAt: new Date(),
      },
      {
        key: "payout_fee_flat",
        value: "20",
        description: "Default flat fee for payouts",
        createdAt: new Date(),
        updatedAt: new Date(),
      },
    ]);
  },

  down: async (queryInterface, Sequelize) => {
    await queryInterface.dropTable("Settings");
  },
};
