import 'dotenv/config';

import postgres from 'postgres';
import { env } from '@/lib/env';

async function main() {
  const sql = postgres(env.DATABASE_URL);
  const users =
    await sql`SELECT id, email, name, email_verified, created_at FROM "user" ORDER BY created_at DESC LIMIT 20`;
  console.log('--- user ---');
  console.log(JSON.stringify(users, null, 2));
  const profiles =
    await sql`SELECT user_id, display_name, is_super_admin, is_active FROM user_profiles ORDER BY created_at DESC LIMIT 20`;
  console.log('--- user_profiles ---');
  console.log(JSON.stringify(profiles, null, 2));
  const accounts =
    await sql`SELECT user_id, provider_id, account_id FROM account ORDER BY created_at DESC LIMIT 20`;
  console.log('--- account ---');
  console.log(JSON.stringify(accounts, null, 2));
  await sql.end();
}
main().catch((e) => {
  console.error(e);
  process.exit(1);
});
