Is it possible to create branches without data (just the structure)
I saw an option for this a while ago, it's not there anymore
17 Replies
adverse-sapphire•13mo ago
Hey! It's not possible to create branches without data. Do you mind sharing more details about your use case?
I saw an option for this a while agoHmm, we never had that in the console
correct-apricotOP•13mo ago
I'm surprised because this is a pretty standard use case for companies that have integration with external systems such as Salesforce, CRMs, lending systems, financial systems, most systems, actually.
Eg. An external system typically assigns IDs for "field" mappings, and various integration configs. These differ by environment, so companies will typically seed this for testing or dev environments.
They will differ in production
adverse-sapphire•13mo ago
As a workaround you can create a branch from production and truncate the tables (this would remove all data). You can then create copies from this "template" branch
adverse-sapphire•13mo ago
so it's like this

correct-apricotOP•13mo ago
Right, but when we truncate, we've technically appended data change. Which means we'll be charged for production data (let's say we have 2TB in prod)
adverse-sapphire•13mo ago
Right, but when we truncate, we've technically appended data change.Right, that's the downside, but you will need to do this once (whichI understand is not ideal in the first place). Then you'll apply schema changes across branches so dev -> template -> main This is something we plan on addressing cc @brian-holt
correct-apricotOP•13mo ago
Is that not true?
I just signed up for a base $20 plan a few days ago and trying to understand Neon.
I'm building my next company. We just closed a funding round led by M13 (https://m13.co). We’re currently in stealth mode and plan on launching in 2025.
adverse-sapphire•13mo ago
Congrats! We'd love to know your feedback
correct-apricotOP•13mo ago
In your above example, once we update DDLs in protected prod branch, we'll need to reset
template (from prod) and make this data change (truncate tables), right?
template will then be seeded with configs and then engineers can branch of thatadverse-sapphire•13mo ago
once we update DDLs in protected prod branch, we'll need to reset template (from prod) and make this data change (truncate tables), right?Not really. You'll apply DDLs to the template branch first and then re-apply them to production. This way, the schema will always be in sync. You would reset the branch if you want the latest schema and data What's your tech stack? Applying DDLs can be automated as part of your CI pipeline
correct-apricotOP•13mo ago
Services are Go and Node/TS. Node will be connected to PG for APIs. We're planning on using drizzle
Data & ML stack is fairly complicated, lots of things
adverse-sapphire•13mo ago
Drizzle is a solid choice 😄
You can use Drizzle-kit to generate migrations and apply them in your CI/CD pipeline. Here's an example where we're creating a Neon preview branch for every pull request https://github.com/neondatabase-labs/preview-branches-with-fly
GitHub
GitHub - neondatabase-labs/preview-branches-with-fly: A Neon branch...
A Neon branch for every Fly Preview app. Contribute to neondatabase-labs/preview-branches-with-fly development by creating an account on GitHub.
correct-apricotOP•13mo ago
Trying to also figure out best way to generate & perform migrations -- via drizzle, via neon CLI diff. or manually by hand.
Drizzle doesn't seem to support postgres DOMAINS
adverse-sapphire•13mo ago
Drizzle supports custom types https://orm.drizzle.team/docs/custom-types
via drizzleDefinitely that would be the best option. You define your schema using TS, and you have SQL generated. It's easier and less error-prone
Drizzle ORM - Custom types
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
correct-apricotOP•13mo ago
Alright, thanks. I'll give that a shot this week.
I've used this before: https://github.com/ariga/atlas
adverse-sapphire•13mo ago
btw, you can apply here to receive startup credits https://neon.tech/yc-startups
we make exceptions to VC backed companies
correct-apricotOP•13mo ago
Awesome, thanks