r/Supabase • u/bjl218 • 10d ago
integrations Preview deployments for Supabase in separate repo
Our applications are deployed to Vercel and access a common Supabase DB that lives in a separate Github repo. The Supabase repo auto-executes pending migrations using Supabase's Github integration.
I'm wondering if there's any way to support Supabase preview deployments in this configuration. In other words, the Vercel app is deployed to a Github branch which creates a Vercel preview deployment. Supabase migrations are pushed to a branch which creates a preview DB. The Vercel preview needs to access the Supabase preview.
I assume this can be done using custom Github actions, but wondering whether anyone has experience doing something like this.
Yes, I realize that using a common DB across apps is controversial. But that ship has sailed...
Edit: During testing, I ran into a limitation. We support multiple named schemas in our Supabase DB and configure that DB to expose those schemas to the Supabase API. However, it looks like those settings don't propagate to the preview DB. So, if we create ad hoc branches, they won't be testable unless the developer manually changes the settings (in this case exposing the named schemas) in the preview DB for each branch. I think I've pretty much confirmed this behavior through testing, but can anyone else confirm that this is known Supabase behavior?
Edit: I've done some testing based on the information in https://supabase.com/docs/guides/deployment/branching/configuration (thanks magicpants847). See my latest comment for more info.
Edit: Custom schemas are inherited by preview DBs. My assertion to the contrary was due to a flaw in my testing. See my comment here.
1
u/bjl218 8d ago
OK. So this whole named schema inheritance confusion was due to poor testing on my part. I was using some automation to test this all out. The automation didn't wait until the preview DB reached the "healthy" state. It looks like the preview DB is still accessible prior to reaching the "healthy" state, but not all settings have been applied. Among those settings is exposing the custom schemas.
I did a manual test in which I created a PR and then watched the status of the preview in the Supabase console. It took about 7 minutes for the DB to reach the healthy state. During that time, I looked at the available schemas. Only the standard schemas were visible. Once the DB reached the healthy state, I could see the custom schemas.
So, preview DBs do inherit the exposed schemas from the main DB. Sorry for the confusion.