Files
apex/server/scripts/haefele-inspect.js
lejayandCursor 6c0d7e47b8 v2.0
Co-authored-by: Cursor <[email protected]>
2026-05-28 07:20:38 +02:00

39 lines
1017 B
JavaScript

import { query } from '../db/index.js';
async function main() {
const countSql = `
SELECT COUNT(*) as c
FROM formex_materials
WHERE (
supplier_id = (SELECT id FROM suppliers WHERE code = 'haefele')
OR collection = 'Hafele'
OR formex_code LIKE 'HAF-%'
)
`;
const count = await query(countSql);
console.log('haefele_count', count.rows[0]?.c ?? 0);
const sampleSql = `
SELECT id, formex_code, name, collection, supplier_id, last_synced_at
FROM formex_materials
WHERE (
supplier_id = (SELECT id FROM suppliers WHERE code = 'haefele')
OR collection = 'Hafele'
OR formex_code LIKE 'HAF-%'
)
ORDER BY last_synced_at DESC, id DESC
LIMIT 10
`;
const sample = await query(sampleSql);
console.log('haefele_sample', sample.rows);
const syncCols = await query("PRAGMA table_info(sync_logs)");
console.log('sync_logs_cols', syncCols.rows.map((c) => c.name));
}
main().catch((err) => {
console.error(err);
process.exit(1);
});