N
Neon2y ago
absent-sapphire

Using a non-primary branch when cloning for previews in Vercel integration

Hey! I’m working on migrating to using Neon for our already launched Vercel project. I’m very excited that the Vercel Integration is GA and I’m eager to start using it once the transition PRs go to production. One thing I’m hung up on: Can I use a branch for cloning for previews that is not the primary branch? I want to keep the production branch set to primary, but use a different branch, say, preview-template, when generating preview branches. The reason for this is that our ISG pages are many — more than 10k pages, thoughour DB is only 40mb — and pre generating all those pages is time and resources consuming. I would rather only pull the full production db into staging, and previews on demand when necessary, but begin from a smaller sandbox template for previews. Let me know if my idea of using a different template branch is possible, or if there’s another approach I’m not considering. Thanks!
5 Replies
afraid-scarlet
afraid-scarlet2y ago
To make sure there's no misconceptions here, creating a branch is instant and does not depend on the size of the database you are branching from. It also does not add any extra storage cost. Whether you use primary or smaller for previews it will not be any different in speed or storage. In the neon console and API you can branch from other branches just fine. I'm not familiar with the ins and outs of the vercel integration but I assume it is exposed there as well. I'll have to check Hmm, I don't see any settings in the documentation that indicates using a different preview branch. That's a bit unfortunate. CC @Mike J
metropolitan-bronze
metropolitan-bronze2y ago
I raised this a while back and believe it's in the backlog @Conrad Ludgate @Zach P Hopefully @Mike J can share more specifics.
absent-sapphire
absent-sapphireOP2y ago
Thanks for the response! Yea, I appreciate the clarification about instant and efficient branching. The inefficiency is the vercel build step, which is related to the size of the database Bummer that it’s not yet configurable with the vercel integration. That would be a huge help. As a workaround, I could set the hypothetical preview-template branch as primary, and use a production branch that is separate. Is there a downside to this? Does setting a branch as primary have any other effect than making it the default for branching? Is there a way to protect branches from being accidentally deleted or manually manipulated?
metropolitan-bronze
metropolitan-bronze2y ago
Is there a way to protect branches from being accidentally deleted or manually manipulated?
Not at present no.
As a workaround, I could set the hypothetical preview-template branch as primary, and use a production branch that is separate. Is there a downside to this? Does setting a branch as primary have any other effect than making it the default for branching?
There are a few considerations t bear in mind, but that can work yes: https://neon.tech/docs/guides/branch-promote#what-is-a-primary-branch
Neon
Promote a branch - Neon Docs
This guide describes how to create a new branch and promote it to the primary branch of your Neon project in the context of a data recovery scenario. It also describes how to move the compute endpoint...
national-gold
national-gold2y ago
Hey! Confirming I have branching from non-primary as a backlog item for the Vercel integration. In the spirit of transparency, it's not high on my priority list right now so I don't have an indicative date to share 😔. While it won't cause harm, it's a common assumption primary = production. Another idea: would it be feasible to have some logic in your getStaticPaths (or similar) that limits what's built if it's not a production deployment? This idea comes with the caveat I am not an engineer!

Did you find this page helpful?