Hacker News new | ask | show | jobs
by swaraj 1099 days ago
I haven't used Codespaces, but how does this work with databases? A common problem we have during onboarding is getting your local database (MySQL) setup properly: run all the migrations => load some sample, de-identified, production-like data => update certain rows to allow for personal development (e.g. for our texting service, make sure you text your own phone number, instead of someone else's).

What's the workflow for this?

A related issue for us is being able to test another developer's pull request with database migrations without wiping out your current database state. Is there a Devpods workflow for this?

3 comments

If you can script your setup steps, you can also run it in a devcontainer, either by using docker-compose[1] to bake it into the workspace image or using lifecycle hooks to run some scripts after creating the workspace[2]

[1]http://blog.pamelafox.org/2022/11/running-postgresql-in-devc... [2]https://github.com/pascalbreuninger/devpod-react-server-comp...

We've built www.snaplet.dev to introduce the exact workflow that you're describing. Unfortunately we're PostgreSQL only at the moment.

We give you a serverless PostgreSQL database per branch in your code. [via Neon.tech] Each time you branch your code we grab the latest snapshot of your production database which is de-identified and transformed [Transformations are via TypeScript] and a subset of the original.

If a coworker and yourself are coding against the same branch you're coding against the same database.

Your devs only run a single command `snaplet dev` and all this happens automatically in the background.

This looks amazing, we have written a similar script for both our local dev dbs as well as our staging env. Would love MySQL support
We'll add it as soon as we've found figured out the core experience, we're close. V1.0 is just around the corner, and then we'll add MySQL and SQLite.
This exact workflow is why we have integrated Cloud IDE with full-stack branch preview (both of which know about database seed/migrations) at Coherence (withcoherence.com). [disclaimer - I’m a cofounder]. You can also integrate other seeding tools like snaplet, mentioned in a sibling comment here, which is an awesome solution to this problem!

Would be happy to discuss getting a PoC setup to see if it helps in your case, or to answer any questions, feel free to reach out