activerecord-safer_migrations
activerecord-safer_migrations copied to clipboard
Support block based invokations
Sometimes migrations do quite a lot of things and you might need different locks/timeouts inside a single change/up/down:
def change
with_timeout lock: 10.seconds do
# ...
end
# ...
with_timeout statement: 10.minutes do
# ...
end
# ...
with_timeout lock: 5.seconds, statement: 10.hours do
# ...
end
end
Hi @krainboltgreene,
Thanks for the suggestion. We'll have a think about it.
Our current approach to this is to bundle changes with similar requirements into their own migration files. They can still go out in a single deployment, so we don't find it's a huge amount of overhead.
I hear ya, there's not an incredibly compelling reason for it other than it mimes other active record interfaces (and ones they've recently introduced as an addition, see: add_foreign_key and table.foreign_key).
@krainboltgreene (hi!) what timeout would you expect to be applied to code executed outside of the with_timeout block? I guess it'd all be in the same transaction & would run a lot of set commands to switch between the local override & the default as configured in the gem?