Can I Skip Code-Based Migration and Just Use drizzle-kit migrate?

I’m using Drizzle ORM and noticed there are two ways to run migrations: using the drizzle-kit migrate command and the code-based approach (migrate function). Do I need both, or can I rely solely on the drizzle-kit migrate command to handle my database migrations? What even is the difference between the two? Thanks for the help
6 Replies
Luc
Luc5mo ago
just use the cli, it uses the migrator under the hood saves you from writing a migrator file
jem
jemOP5mo ago
Thats what im currently using. Just generally curious whats the use case for the code-based approach.
Luc
Luc5mo ago
its for running migrations programmatically if you have logic that needs that
jem
jemOP5mo ago
watched some tutorials they all seem to use the code-based migration approach. I thought i was doing something wrong lol.
Kuba
Kuba5mo ago
The code-based migration comes handy when setting up integration tests. Both approaches are valid
jem
jemOP5mo ago
Oh that make more sense! Thanks!

Did you find this page helpful?