N
Neon13mo ago
correct-apricot

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
adverse-sapphire13mo 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 ago
Hmm, we never had that in the console
correct-apricot
correct-apricotOP13mo 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
adverse-sapphire13mo 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
adverse-sapphire13mo ago
so it's like this
No description
correct-apricot
correct-apricotOP13mo 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
adverse-sapphire13mo 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-apricot
correct-apricotOP13mo 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
adverse-sapphire13mo ago
Congrats! We'd love to know your feedback
correct-apricot
correct-apricotOP13mo 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 that
adverse-sapphire
adverse-sapphire13mo 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-apricot
correct-apricotOP13mo 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
adverse-sapphire13mo 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-apricot
correct-apricotOP13mo 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
adverse-sapphire13mo ago
Drizzle supports custom types https://orm.drizzle.team/docs/custom-types
via drizzle
Definitely 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-apricot
correct-apricotOP13mo ago
Alright, thanks. I'll give that a shot this week. I've used this before: https://github.com/ariga/atlas
adverse-sapphire
adverse-sapphire13mo ago
btw, you can apply here to receive startup credits https://neon.tech/yc-startups we make exceptions to VC backed companies
Neon
NEON YC Startups
Special Deal For YC Startups
correct-apricot
correct-apricotOP13mo ago
Awesome, thanks

Did you find this page helpful?