Need data for your database? Whether you’re setting up a test to validate a feature, or preparing a new development environment from scratch, seeding your database can often feel like a chore.
If you’re a Prisma user though, Prisma’s integrated seeding functionality combined with Snaplet makes seeding your database a breeze!
Prisma Migrate x Snaplet Restore
Prisma, with its intuitive approach to database migrations, is already a favorite tool for many developers. It simplifies database schema changes, making them more manageable and less error-prone. Now, combine this with Snaplet, and you have a powerhouse duo that not only structures your database efficiently but also populates it with data that mirrors your production environment.
There’s two moving parts:
- Prisma Migrations: Prisma Migrate auto-generates SQL migrations from your Prisma schema, so you don’t need to write the SQL by hand. These migration files are fully customizable, giving you full control and ultimate flexibility — from local development to production environments..
- Snaplet Restore: This is where Snaplet steps in. Once you have your schema set up, Snaplet takes over to fill your database with realistic, yet safe, data. No need to write a cumbersome seed script.
The process is straightforward:
- Run prisma migrate dev to get your database schema up to speed.
- Use snaplet restore --data-only to pump in the data, giving you a development environment that mirrors real-world complexities without any of the risks.
- Rapid Development Cycles: For those who iterate fast, this integration means less time fiddling with data and more time building features.
- New Developer Onboarding: New team member? Get them up and running with a database that reflects the current state of your production, minus the sensitive data.
- Testing Complex Interactions: Testing complex user interactions or data relationships? Realistic data helps you catch those edge cases early.
- Demonstrations and Prototypes: Need to showcase your project? Use data that tells the real story of how your application works.