N
Neon17mo ago
rare-sapphire

Integrating with platforms that have dev + prod environments

Hello, I could use help with a question I'm having with using Neon alongside other platforms: We're using a 3rd-party platform to handle authentication. They provide a dev environment and a prod environment. We want to sync some data from the auth provider to our Neon database. For example: 1. User signs up 2. Auth provider saves user's name and email (along with other auth data) 3. We want to replicate name, email, and auth_id in an "accounts" table on our Neon database. If our Neon default branch represents prod that maps to prod auth data, how would we handle maintaining a dev branch that maps to dev auth data? It seems like we cannot ever do something like "reset from parent" because we want to preserve the separate environment auth data. But if there isn't a reason to branch off main, it seems like we go back to the traditional method of having to keep two databases in sync, losing out on some benefits of branching and using Neon. Am I not thinking of some alternatives here? If there aren't alternatives, are there any best practices you can recommend, e.g. two databases within a Neon project vs two Neon projects?
8 Replies
plain-purple
plain-purple17mo ago
You can create a branch from a branch in Neon So you can have: 1. Main branch for production 2. Set up another branch that contains the auth dev data. You can then create development branches from that branch
No description
plain-purple
plain-purple17mo ago
You can then reset the dev branch from its parent Schema changes can be worked on while using a dev branch, then changes should be reapplied to the branch with auth dev data and then to the main branch
rare-sapphire
rare-sapphireOP17mo ago
Thank you for the response! What are the benefits of having "branch with auth data" being a branch off "main" vs being a separate database?
plain-purple
plain-purple17mo ago
Well databases reside in a branch - main - prod - dev So if you create a branch, prod and dev will be copied to the child branch. Using a separate branch offers better isolation
rare-sapphire
rare-sapphireOP17mo ago
I see, that makes sense. What about benefits of branching off main vs a separate Neon project for dev?
plain-purple
plain-purple17mo ago
Having separate projects can work, but it won't provide you with the best development experience since it doesn't follow the typical project per app model (for example, you will need to keep track of two project IDs in your CI, you will be looking at two different projects in the console, etc.)
rare-sapphire
rare-sapphireOP17mo ago
Got it, thank you! It still feels a bit strange that there’s always a risk that "branch with auth data" can be reset from the parent as a branch on accident (I know there’s rollback). Are there any protections to prevent that from happening?
plain-purple
plain-purple17mo ago
Not yet, but we're working on adding support for fine-grained access control when it comes to branches

Did you find this page helpful?