#!/usr/bin/env node import pg from 'pg'; import { readFileSync } from 'fs'; const userId = process.argv[2] || '7be0cbbf-8755-4047-b5ab-2038416d4013'; const env = readFileSync('/opt/ai-fresh-delivery/server/.env', 'utf8'); const url = env.match(/^DATABASE_URL=(.+)$/m)[1].trim().replace(/^["']|["']$/g, ''); const pool = new pg.Pool({ connectionString: url }); try { const audit = await pool.query( `SELECT action, entity_type, entity_id, details, created_at, actor_id FROM audit_logs WHERE entity_id = $1 OR details::text ILIKE '%17883314362%' ORDER BY created_at DESC LIMIT 20`, [userId] ); console.log('audit_logs:', audit.rowCount); audit.rows.forEach((r) => console.log(JSON.stringify(r))); const bindings = await pool.query( `SELECT * FROM purchaser_users WHERE user_id = $1`, [userId] ); console.log('\npurchaser_users:', bindings.rows); } finally { await pool.end(); }