You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So migrations are generated or written in SQL which is inherently a good thing, but that poses a few issues.
It doesn't allow for shuffling data around with specific migrations.
You don't get to piggy-back on the transactional nature of the migration.
You have to synchronize the with up/down migrations manually which is most likely going to be error-prone.
Can't piggy-back on SHARE UPDATE EXCLUSIVE lock or whatever drizzle is currently using.
This is an issue if you want to launch multiple node and have the migrations run on boot and at the same time move data around in S3 or Redis.
My suggestions are that migrations should have a programmatic API:
to run up/down to N where N defaults to latest for up.
Allow for registering callbacks for up/down calls with specific identifiers so you can manage typescript code running inside the transaction alongside the specific migration in question.
The lock should be on a database level as default (e.g SHARE UPDATE EXCLUSIVE) but of course allow op-tin for advisory locks.
For every SQL migration, it will run the associated up or down function registered for said callback. If the callback fails, the migration fails, and if the migration fails, the callback cancels or even runs down
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
So migrations are generated or written in SQL which is inherently a good thing, but that poses a few issues.
SHARE UPDATE EXCLUSIVE
lock or whatever drizzle is currently using.This is an issue if you want to launch multiple node and have the migrations run on boot and at the same time move data around in S3 or Redis.
My suggestions are that migrations should have a programmatic API:
up/down to N
whereN
defaults to latest forup
.up/down
calls with specific identifiers so you can manage typescript code running inside the transaction alongside the specific migration in question.SHARE UPDATE EXCLUSIVE
) but of course allow op-tin for advisory locks.For every SQL migration, it will run the associated
up
ordown
function registered for said callback. If the callback fails, the migration fails, and if the migration fails, the callback cancels or even runsdown
Same for
down
calls.Slightly related to #2832
Beta Was this translation helpful? Give feedback.
All reactions