const dotenv = require("dotenv");
const { pool, ensureDatabase } = require("./db");

dotenv.config();

const SEED_CONFIRMATION = "YES_WIPE_AND_SEED";

if (process.env.ALLOW_SEED !== SEED_CONFIRMATION) {
  console.error(
    `Seed blocked. To run intentionally, set ALLOW_SEED=${SEED_CONFIRMATION} for this command.`
  );
  process.exit(1);
}

const samplePlayers = [
  "Starified",
  "ProtectionZ",
  "DopeyDude",
  "Morocco",
  "chubbsge",
  "Madhansh",
  "moorona",
  "Nepa",
  "Krilbex",
  "Genvrousbooch",
  "Rocketer",
  "LeosinEdits",
];

async function seed() {
  await ensureDatabase();

  for (const username of samplePlayers) {
    await pool.query("INSERT IGNORE INTO players (username) VALUES (?)", [username]);
  }

  console.log("Seed complete (players only, no rank assignment).");
  process.exit(0);
}

seed().catch((error) => {
  console.error("Seed failed:", error);
  process.exit(1);
});
