Don't silently execute statements on migrations when they can't be reversed

Fixes #51570.
This commit is contained in:
Rafael Mendonça França 2024-04-18 23:00:20 +00:00
parent 270ed27cec
commit 5b04d448ab
No known key found for this signature in database
GPG Key ID: FC23B6D0F1EEE948
3 changed files with 15 additions and 2 deletions

@ -1,3 +1,9 @@
* Don't silently execute statements on migrations when they can't be reversed.
Fixes #51570.
*Rafael Mendonça França*
* Allow `Sqlite3Adapter` to use `sqlite3` gem version `2.x`
*Mike Dalessio*

@ -376,9 +376,10 @@ def respond_to_missing?(method, _)
super || delegate.respond_to?(method)
end
# Forwards any missing method call to the \target.
# Forwards any missing method call to the target.
def method_missing(method, ...)
if delegate.respond_to?(method)
record(method, ...)
delegate.public_send(method, ...)
else
super

@ -46,12 +46,18 @@ def test_inverse_of_raise_exception_on_unknown_commands
assert_raises(ActiveRecord::IrreversibleMigration) do
@recorder.inverse_of :execute, ["some sql"]
end
assert_raises(ActiveRecord::IrreversibleMigration) do
@recorder.inverse_of :update, ["some sql"]
end
end
def test_irreversible_commands_raise_exception
assert_raises(ActiveRecord::IrreversibleMigration) do
x = assert_raises(ActiveRecord::IrreversibleMigration) do
@recorder.revert { @recorder.execute "some sql" }
end
assert_raises(ActiveRecord::IrreversibleMigration) do
@recorder.revert { @recorder.update "some sql" }
end
end
def test_record