Fix t.references validating options on Rails < 7.1

Option validation was [added][1] for 7.1+ Migration classes, and a
compatibility layer was added to ensure that previous Migration versions
do not have their options validated. However, the `t.references` method
was missing in the compatibility layer which results in pre 7.1
Migrations validating options passed to `t.references`.

This commit fixes the issue by adding t.references to the compatibility
layer.

See also a [similar fix][2] for `add_reference`

[1]: e6da3ebd6c
[2]: 71b4e22301
This commit is contained in:
Hartley McGuire 2024-01-16 17:18:01 -05:00
parent 299900f4e5
commit 327f28b65f
No known key found for this signature in database
GPG Key ID: E823FC1403858A82
3 changed files with 7 additions and 1 deletions

View File

@ -1,5 +1,5 @@
* Fix Migrations with versions older than 7.1 validating options given to
`add_reference`.
`add_reference` and `t.references`.
*Hartley McGuire*

View File

@ -82,6 +82,11 @@ module ActiveRecord
super
end
def references(*args, **options)
options[:_skip_validate_options] = true
super
end
private
def raise_on_if_exist_options(options)
end

View File

@ -673,6 +673,7 @@ module NoOptionValidationTestCases
change_table :tests do |t|
t.change :some_id, :float, null: false, wrong_index: true
t.integer :another_id, wrong_unique: true
t.references :yet_another_table, bad: :option
end
end
}.new