require('dotenv').config(); const { Pool } = require('pg'); (async () => { const pool = new Pool({ connectionString: process.env.DATABASE_URL }); const r = await pool.query(` SELECT id, branch_code, config_key, length(config_value::text) AS len, config_value, updated_at FROM system_configs WHERE config_key = 'nav_menu_layout' ORDER BY branch_code NULLS FIRST `); for (const row of r.rows) { const cv = row.config_value; const summary = cv && typeof cv === 'object' ? { version: cv.version, groupCount: Array.isArray(cv.groups) ? cv.groups.length : 0, standaloneCount: Array.isArray(cv.standalone) ? cv.standalone.length : 0, orderCount: Array.isArray(cv.order) ? cv.order.length : 0, groupLabels: Array.isArray(cv.groups) ? cv.groups.map((g) => g.label) : [], standaloneKeys: Array.isArray(cv.standalone) ? cv.standalone.map((s) => s.menuKey) : [], } : null; console.log(JSON.stringify({ branch_code: row.branch_code, len: row.len, updated_at: row.updated_at, summary }, null, 2)); } await pool.end(); })().catch((e) => { console.error(e); process.exit(1); });