Is it safe to delete a parent branch?
If branch B has parent branch A, can I delete branch A without affecting the data in branch B?
Use case: I would like to make modifications to a branch in development and then promote it to production after I have completed modifications and can confirm the changes are good. At that point, the original branch is not useful to keep around.
5 Replies
fair-roseOP•7mo ago
Actually, I see that neon doesn't actually allow me to delete branches with children
What if I could do the equivalent of squashing branches? For now I guess I will leave archive branches there to keep the structure available, but I'll eventually hit account limits
optimistic-gold•7mo ago
Hey, you're right. You cannot delete a branch that has children. We hope to address this limitation in the future. What you can do to avoid hitting limits in this scenario is to drop databases from branch A after you're sure you no longer need the schema & data on branch A.
However, the workflow we suggest would be to create branch B as your dev branch. Do your development work on branch B, and then migrate your schema changes to branch A.
fair-roseOP•7mo ago
for now I think I'm going to be just making a long chain of databases A -> B -> C ... n, and worst case I can collapse them when it becomes an issue at my 5k limit, but hopefully y'all can address the limit before that 😅
it would be nice if at least Neon could handle backup and restore across databases within its own walls, without having to write the backup to my own disk as an intermediary
optimistic-gold•7mo ago
We just introduced a feature called "Schema-only branches." These create a new "root" branch in your project, meaning that you can create Branch B, copying only the schema from Branch A. Because Branch B is a new root branch, there's no restriction on dropping Branch A. However, data is not being copied from Branch A to Branch B in this scenario, only the schema. But it sounds like you need the data as well on Branch B?
https://neon.tech/docs/guides/branching-schema-only
Neon
Schema-only branches - Neon Docs
Neon supports creating schema only branches, letting you create branches that replicate only the database schema from a source branch — without copying any of the actual data. This feature is ideal fo...
fair-roseOP•7mo ago
yeah, I'm using the branches to do some basic data management change control