@@ -0,0 +1,24 @@
|
||||
import { query } from '../db/index.js';
|
||||
|
||||
async function main() {
|
||||
const tables = (await query("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name")).rows.map(
|
||||
(r) => r.name
|
||||
);
|
||||
console.log('tables', tables);
|
||||
|
||||
const counts = ['formex_materials', 'formex_variants', 'formex_dimensions', 'finishes', 'products', 'suppliers'];
|
||||
for (const t of counts) {
|
||||
try {
|
||||
const r = await query(`SELECT COUNT(*) as c FROM ${t}`);
|
||||
console.log(t, r.rows[0]?.c);
|
||||
} catch {
|
||||
console.log(t, '(missing)');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user