Custom query at the end of migrations

So for some context, i use Durable objects which require me to run the migrate function alot. most of the time this will be skipped because the db has not changed so its not an issue. But i was wondering what would be a good way of running a pragma optimize at the end? i only want to run this IF there has been changes aka if the migrations arent skipped. Simple way is obviously manually adding that query in the last migration file but i was wondering if there is another way of doing this? the migrate function sadly dosent return a result that says if migrations ran or were skipped
1 Reply
zsmooth
zsmooth3d ago
I also have this question… and another semi-related one… My app creates new DO’s all the time, so usually when a DO starts, it will actually have to run all migrations. I’d like to somehow have migrations smart enough to just create everything up front for a new db, and also smart enough to run migrations if it’s an existing db. Haven’t thought through completely yet how this would work. I think best would be is if drizzle created a “full migration” for incremental migration is creates, and if starting with an empty db, just runs the full migration (and marks all the incremental migrations as run, so it can add new incremental migrations in the future)

Did you find this page helpful?