'use strict';
const { v4: uuidv4 } = require('uuid');

/**
 * Seeder: Default Admin IP Whitelist
 * 
 * IMPORTANT NOTE ON IP ADDRESSES:
 * ----------------------------------
 * The IPs seeded here must be STATIC/FIXED IPs — meaning IPs that are
 * permanently assigned to your server or machine and do NOT change.
 * 
 * Types of IPs suitable for whitelisting:
 *  - Static IP from your ISP (business internet plan)
 *  - Your server's public IP (e.g. VPS, dedicated server)
 *  - VPN exit IP (if your team uses a VPN with a fixed exit node)
 *  - 127.0.0.1 / ::1 — localhost (always safe for development)
 * 
 * DO NOT whitelist dynamic IPs (typical home/office IPs that reset
 * when the router is restarted). If you lose access, you can always
 * clear the table and the system falls back to SUPERADMIN_ALLOWED_IPS in .env.
 */

/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up(queryInterface, Sequelize) {
    await queryInterface.bulkInsert('AdminIpWhitelists', [
      {
        id: uuidv4(),
        ipAddress: '159.198.46.102',
        description: 'Localhost - Development & Testing',
        status: 'active',
        addedBy: null,
        createdAt: new Date(),
        updatedAt: new Date(),
      },
      {
        id: uuidv4(),
        ipAddress: '102.89.76.8',
        description: 'Localhost IPv6 - Development & Testing',
        status: 'active',
        addedBy: null,
        createdAt: new Date(),
        updatedAt: new Date(),
      },
      {
        id: uuidv4(),
        ipAddress: '105.113.49.174',
        description: 'Super Admin - Primary Office/ISP IP',
        status: 'active',
        addedBy: null,
        createdAt: new Date(),
        updatedAt: new Date(),
      },
      {
        id: uuidv4(),
        ipAddress: '102.89.82.141',
        description: 'Super Admin - Primary Office/ISP IP',
        status: 'active',
        addedBy: null,
        createdAt: new Date(),
        updatedAt: new Date(),
      },
    ]);
  },

  async down(queryInterface, Sequelize) {
    await queryInterface.bulkDelete('AdminIpWhitelists', {
      ipAddress: ['127.0.0.1', '::1', '102.89.83.63'],
    });
  }
};
