Don't silently execute statements on migrations when they can't be reversed
Fixes #51570.
This commit is contained in:
parent
270ed27cec
commit
5b04d448ab
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user