Prisma migration commands are long and confusing, here is a list of 5 commands that you need to effectively run migrations
Migrating a Prisma Database: My Workflow
––– views
1 min read
JSON package.json
"scripts": {"migrate:status": "prisma migrate status","migrate:dev": "prisma migrate dev","migrate:resolve": "prisma migrate resolve --applied $MIGRATION","migrate:deploy": "prisma migrate deploy","migrate:push": "prisma db push"}
In my prisma/.env file I keep all the different databases that I need to connect to.
PLAIN TEXT
DATABASE_URL=postgresql://postgres:damjan@localhost/dbname// the db we're targeting is on the bottomDATABASE_URL=postgresql://postgres:damjan@localhost/mylocaldb
The first one (dbname) is an empty local database, whenever I need to create a new migration I always switch to this DB, to not lose any data from the one I’m using.
📢
I suggest you have 2 local databases one for keeping test data and one for migration
🔥
When adding new properties to an existing model make sure they have a default value or are not required.
To comment please authenticate