/**
 * One-off: widen orac_snaps.snap_timing so POST /api/orac_snaps can store JSON
 * (risk_violation_time + marks). Safe to run multiple times if already MEDIUMTEXT.
 */
import "dotenv/config";
import mysql from "mysql2/promise";

const {
  DB_HOST = "127.0.0.1",
  DB_PORT = "3306",
  DB_USER = "root",
  DB_PASSWORD = "12345"
} = process.env;

const sql = `
ALTER TABLE \`orac_snaps\`
  MODIFY COLUMN \`snap_timing\` MEDIUMTEXT NULL
`;

async function main() {
  const conn = await mysql.createConnection({
    host: DB_HOST,
    port: Number(DB_PORT),
    user: DB_USER,
    password: DB_PASSWORD,
    database: "hse"
  });
  try {
    await conn.query(sql);
    console.log("OK: orac_snaps.snap_timing is now MEDIUMTEXT");
  } finally {
    await conn.end();
  }
}

main().catch((err) => {
  console.error(err.message || err);
  process.exit(1);
});
