#!/bin/bash set -euo pipefail cd /opt/ai-fresh-delivery/server node <<'NODE' require('dotenv').config(); const { Pool } = require('pg'); (async () => { const pool = new Pool({ connectionString: process.env.DATABASE_URL }); const run = async (label, sql) => { const r = await pool.query(sql); console.log('\n===', label, '==='); console.table(r.rows); }; await run('users', 'SELECT id, email FROM auth.users ORDER BY email'); await run('profiles', 'SELECT id, username, full_name, branch_code, status FROM profiles ORDER BY username'); await run('roles', `SELECT p.username, ur.role::text AS role FROM user_roles ur JOIN profiles p ON p.id = ur.user_id ORDER BY p.username, ur.role`); await run('branches', 'SELECT branch_code, branch_name FROM branches ORDER BY branch_code'); await run('customers', 'SELECT customer_code, company_name, branch_code FROM customers ORDER BY customer_code'); await run('orders', 'SELECT order_code, customer_code, branch_code, total_amount FROM orders ORDER BY order_code'); await run('counts', `SELECT 'orders' AS t, count(*)::int AS c FROM orders UNION ALL SELECT 'customers', count(*)::int FROM customers UNION ALL SELECT 'skus', count(*)::int FROM skus UNION ALL SELECT 'suppliers', count(*)::int FROM suppliers UNION ALL SELECT 'inventory', count(*)::int FROM inventory UNION ALL SELECT 'notifications', count(*)::int FROM notifications`); await pool.end(); })().catch((e) => { console.error(e); process.exit(1); }); NODE