|
Hi Supabase Community! I'm developing MyBLlist, a Next.js application using PostgreSQL 17 on Supabase Free as a staging database. Before running our custom database migrations, I want to make sure our setup is compatible with Supabase's managed PostgreSQL environment. Our application schema has already passed offline testing on PostgreSQL 17.11, but we still need clarification about several Supabase-specific requirements. 1. PostgreSQL Catalog VisibilityIs it possible to obtain a complete PostgreSQL catalog inventory through the Supabase SQL Editor or an authorized database role? Specifically, we need to inspect provider-managed objects, schemas, ownership, ACLs, and dependencies. Are there catalog visibility restrictions or provider-managed objects that cannot be fully inspected? 2. Session Pooler and Advisory LocksOur migration runner uses a dedicated PostgreSQL session and session-level advisory locks. Does Supabase's Session Pooler on port 5432 preserve the same PostgreSQL backend throughout the client session, including across transaction boundaries? Is it suitable for custom migration runners that depend on session-level advisory locks? 3. Verified TLS ConnectionsWhat is the recommended configuration for connecting securely to the Session Pooler using Node.js with the We require certificate-chain validation and hostname verification. We previously encountered a timeout during an initial read-only identity query. Are there known Session Pooler configuration considerations or recommended troubleshooting steps for this setup? 4. PostgreSQL ExtensionsOur staging checks currently show:
Can Are there special permission requirements or recommended practices for this? 5. Restricted Application RolesCan we create a separate restricted PostgreSQL runtime role while keeping migration/ownership privileges assigned to another role? Are there Supabase-specific restrictions or recommended privilege configurations for this approach? Additional contextWe are using Supabase only as a managed PostgreSQL database, not Supabase Auth or Storage. Our staging database has not been bootstrapped, and we want to avoid modifying provider-managed objects. I'm particularly interested in official documentation or experiences from developers running custom PostgreSQL migrations on Supabase. Any guidance would be greatly appreciated. Thank you! |
Replies: 1 comment 1 reply
|
For the migration runner, Supavisor session mode on the shared pooler’s port 5432 is the IPv4 alternative to a direct connection. It supports session-level advisory locks across transactions while the connection remains open. Transaction mode on port 6543 is unsuitable for that dependency. Supabase documents this in connection modes and session-state limitations. There is also a client-side requirement: reserve one Postgres.js connection and run the lock, migration statements, and unlock through that reserved client. Using the general For your initial identity check with TLS verification enabled: import postgres from 'postgres'
// Copy the Session pooler URL from Dashboard > Connect.
// Keep it server-side. Use the actual pooler hostname and role.project-ref user.
// Omit URL sslmode parameters; configure TLS explicitly below.
const databaseUrl = process.env.DATABASE_URL
const host = new URL(databaseUrl).hostname
const sql = postgres(databaseUrl, {
max: 1,
connect_timeout: 15,
ssl: { rejectUnauthorized: true, servername: host },
})
try {
const connection = await sql.reserve()
try {
const rows = await connection`
select current_user, current_database(), pg_backend_pid()
`
console.log(rows)
} finally {
await connection.release()
}
} finally {
await sql.end()
}This uses Node's default trusted CAs and checks the pooler hostname. If a custom CA is necessary, add the CA appropriate to that endpoint via the TLS For the remaining preflight questions:
Prepared with AI assistance. The catalog query and reserved-connection/session-lock behavior were checked on an isolated PostgreSQL 17 instance. The hosted pooler and its certificate were not tested against your project. |
For the migration runner, Supavisor session mode on the shared pooler’s port 5432 is the IPv4 alternative to a direct connection. It supports session-level advisory locks across transactions while the connection remains open. Transaction mode on port 6543 is unsuitable for that dependency. Supabase documents this in connection modes and session-state limitations.
There is also a client-side requirement: reserve one Postgres.js connection and run the lock, migration statements, and unlock through that reserved client. Using the general
sqlpool can select different sessions.sql.reserve()provides this. If the connection is lost, stop the migration attempt and reconcile what committed befo…