/**
 * 检查 attendance_rules 表的实际列结构。
 */
import mysql from "mysql2/promise";
import { config } from "dotenv";

config();

async function main() {
  const conn = await mysql.createConnection(process.env.DATABASE_URL);

  console.log("=== attendance_rules 列结构 ===");
  const [cols] = await conn.query(`SHOW COLUMNS FROM \`attendance_rules\``);
  console.table(
    cols.map((c) => ({
      Field: c.Field,
      Type: c.Type,
      Null: c.Null,
      Default: c.Default,
    }))
  );

  console.log("\n=== leave_requests 表是否存在 ===");
  try {
    const [rows] = await conn.query(`SHOW TABLES LIKE 'leave_requests'`);
    console.log(rows.length > 0 ? "存在" : "不存在");
  } catch (err) {
    console.log("查询失败:", err.message);
  }

  await conn.end();
}

main().catch((err) => {
  console.error("FATAL:", err);
  process.exit(1);
});
