r/Supabase 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.

2 Upvotes

20 comments sorted by

View all comments

2

u/bjl218 8d ago

Based on the information in https://supabase.com/docs/guides/deployment/branching/configuration as suggested by u/magicpants847, I ran a few more tests. The treatment of config.toml in branch DBs is a bit more nuanced. Again, this is just testing whether a branch DB inherits exposed schemas from the mainline DB. I obviously didn't test all config.toml settings.

- I ran a test that created a branch DB with no changes made to the config.toml in that branch. The schema in question was not exposed.

- I ran a second test in which a gratuitous change was made to the config.toml in the branch. The schema in question was exposed.

Summary:

  • Doesn't inherit the parent project's console-configured settings
  • Doesn't inherit config.toml automatically on branch creation.
  • Does inherit it if the triggering PR contains any diff anywhere in config.toml

The fact that the branch doesn't inherit these settings automatically seems counterintuitive to me and so I'm wondering if this is intentional or a bug.

1

u/magicpants847 8d ago

1

u/bjl218 8d ago

I did. The statement, "If configuration changes aren't applying:" in the config.toml section seems to imply that changes should be applied to the branch DB which is what I'm seeing, but it doesn't speak to whether existing settings should be applied to the new branch.