I think I'm missing something about how migrations...
# orm-help
m
I think I'm missing something about how migrations are supposed to be used. Specifically I don't understand why to update my schema during development I need to point prisma to a running database instance. I get that
migrate deploy
needs to point to an actual database instance but why does
migrate dev
? To do its work it just needs the schema and the list of previous migrations, no?
s
It needs to point to a DB instance because it also checks if all migrations are applied.
m
Is there a way to force it not to do that check?
That doesn't seem necessary for a development command. I understand why I would want to do that occasionally but not why it's a hard and fast requirement
s
Then you need to use
prisma db push
m
Unless I misunderstand something that doesn't update the schema
s
So, the migrate dev command is specifically for creating a migration locally and apply it to the database. From the docs:
Prisma Migrate generates a history of
.sql
migration files, and plays a role in both development and deployment.
They also mention this:
If you are prototyping, consider using the db push command
This is the guide on how to prototype using db push https://www.prisma.io/docs/guides/database/prototyping-schema-db-push/
m
OK so db push updates the schema?
s
Yes, it is for rapid prototyping and development.
m
Sorry that's not exact. I mean that I need to regenerate my client after I make a change to the schema.
s
Ah! You can simply run
prisma generate
You don’t need to create a migration or anything for it
m
Ah ok. So if I make a change I can run prisma generate and then at some later point when the db is up and running run the migration
Thanks for clearing that up (assuming I've got this right)
s
No, Prisma generate doesn’t create a migration at all
You can use it to update schema and generate client
Once you’re satisfied, you can then create a migration (if it’s intended for production) or just use db push to push changes to a local instance
m
Yeah, sorry if that seemed confusing. I understand that. Thanks
That clears it all up
s
No problem, glad to help :)
🙏 1