
import { Pool } from 'pg'

const connectionString = process.env.DIRECT_URL || process.env.DATABASE_URL
const pool = new Pool({ connectionString })

async function check() {
  try {
    const res = await pool.query("SELECT id, name, public FROM storage.buckets;")
    console.log("Buckets:", JSON.stringify(res.rows, null, 2))
    
    const res2 = await pool.query("SELECT policyname, cmd, qual, with_check FROM pg_policies WHERE tablename = 'objects' AND schemaname = 'storage';")
    console.log("Policies:", JSON.stringify(res2.rows, null, 2))
  } catch (e) {
    console.error(e)
  } finally {
    await pool.end()
  }
}

check()
