Managing Neon Branch Deletion After PR Merge/Close
Hey Team,
I'm using the Vercel integration with Neon for preview deployments, and it's working well. However, I noticed that when we merge or close a PR, the corresponding preview branch in Neon isn't automatically deleted.
Is there a way to automate this cleanup process? Any insights or best practices would be appreciated.
12 Replies
like-gold•7mo ago
The integration supports automatic branch deletion. Please check this section in the guide for instructions:
https://neon.tech/docs/guides/vercel-previews-integration#manage-branches-created-by-the-integration
Neon
Install the Neon Postgres Previews Integration on Vercel - Neon Docs
What is the Neon Postgres Previews Integration How to install the integration How to manage your integration Neon Postgres Native Integration Vercel Preview Deployments About the integration The Neon ...
like-goldOP•7mo ago
Hey @Daniel,
Could you take a look at this Loom video? https://www.loom.com/share/9ceb995f5b1c4ff2b8d740ea232016ee?sid=c83c0ed8-0431-4ccb-9987-a2f17163b5d2 I'm noticing that when I merge or close the PR, it's not getting deleted as expected.
Would love your insights on this—thanks!
Could you take a look at this Loom video? https://www.loom.com/share/9ceb995f5b1c4ff2b8d740ea232016ee?sid=c83c0ed8-0431-4ccb-9987-a2f17163b5d2 I'm noticing that when I merge or close the PR, it's not getting deleted as expected.
Would love your insights on this—thanks!
Loom
Troubleshooting NeonDB Integration Issues 🛠️
In this video, I'm discussing an issue I'm facing with the Vercel integration when creating a pull request. Even after closing the pull request, the test branch isn't being deleted automatically, which raises the question of whether this is a bug or if there's a fix available. I would appreciate any insights or solutions you might have on this m...
like-gold•7mo ago
Thank you for the video @Priyank T Rajai I am showing this to our Developers. I'll get back to you.
like-goldOP•7mo ago
Thank you @Daniel
like-gold•7mo ago
@Priyank T Rajai An answer from our Developer: "this is the expected behavior. The branch isn't deleted right after the Git branch has been deleted, but only in the next deployment."
I'll check our docs to make sure that behavior is documented.
like-goldOP•7mo ago
Can you please elaborate what does next deployment mean?
like-gold•7mo ago
That would be the next Vercel preview deployment, created by the next commit/push to your repo (which creates a new Neon branch):
https://neon.tech/docs/guides/vercel-previews-integration#use-the-neon-postgres-previews-integration
Neon
Install the Neon Postgres Previews Integration on Vercel - Neon Docs
What is the Neon Postgres Previews Integration How to install the integration How to manage your integration Neon Postgres Native Integration Vercel Preview Deployments About the integration The Neon ...
like-goldOP•7mo ago
Hey @Daniel ,
I did that but it still has this old preview branch which was closed.

like-goldOP•7mo ago
And I have other queries as well
1.NeonDB Integration with Multiple Projects:
Does NeonDB support integration with multiple projects within a monorepo setup? Specifically, can we link one Neon project to each Vercel project when using Turborepo for managing multiple apps within the same repository?
2. Preview Branch Migrations:
When creating a pull request (PR) that targets a preview branch, will NeonDB automatically apply database migrations to the associated preview environment on Vercel? How seamless is the migration process for PR previews?
like-gold•7mo ago
@Priyank T Rajai The Vercel integration supports a 1 Vercel project : 1 Neon Project configuration only.
Please see here for how to automatically apply migrations to branches created for previews: https://neon.tech/docs/guides/vercel-previews-integration#applying-schema-changes-to-database-branches
Neon
Install the Neon Postgres Previews Integration on Vercel - Neon Docs
What is the Neon Postgres Previews Integration How to install the integration How to manage your integration Neon Postgres Native Integration Vercel Preview Deployments About the integration The Neon ...
like-gold•7mo ago
This video also touches on your migration question: https://neon.tech/docs/guides/vercel-previews-integration#video-a-postgres-database-for-every-preview-deployment
like-goldOP•7mo ago
Thank you @Daniel