Migrate only up to a certain migration

Due to the system I'm running I need to run a migration up to a certain point, then run some logic, and only then keep with the normal migrations. This is because the logic I need to mutates data in a certain way. Is there a way to tell this to migrate()?
6 Replies
veeque
veequeOP5mo ago
(durable objects)
oke
oke5mo ago
How about manually sourcing/running the SQL files Drizzle generated - you can run as many SQL migrations as you want
veeque
veequeOP5mo ago
i can't because there can be millions of durable objects, and thus the only realistic way to do it is via code, at runtime (each instance gets its own "mini db")
oke
oke5mo ago
Hmm there doesn't seem to be a way to declare a stop for migration (heck, there's also not really a way to mark a migration as already performed) I am thinking: the migrate function seems to be able to take in a migrationFolder option. You could manually split your migrations into two folders, and then call migrate twice with different folder. This is just a thought though, I'm not sure if it works, especially since the journal.json file likely wouldn't be in both folders
veeque
veequeOP5mo ago
i’ll look more into it, my thinking is to hack something
veeque
veequeOP5mo ago
@oke there is no way, unless i manually mingle with the journal (the migrate function for DO uses that, not the sql files, to know which entries exist). this is prone to breakage. i opened an issue. if you feel inclined i'm more than happy to hear your feedback on this! https://github.com/drizzle-team/drizzle-orm/issues/4512
GitHub
[FEATURE]: Allow partial migrations · Issue #4512 · drizzle-team/...
Feature hasn't been suggested before. I have verified this feature I'm about to request hasn't been suggested before. Describe the enhancement you want to request Using the migrate() fu...

Did you find this page helpful?