Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix t.references validating options on Rails < 7.1 #50773

Merged
merged 1 commit into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion activerecord/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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*

Expand Down
5 changes: 5 additions & 0 deletions activerecord/lib/active_record/migration/compatibility.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ def index(column_name, **options)
super
end

def references(*args, **options)
options[:_skip_validate_options] = true
super
end

private
def raise_on_if_exist_options(options)
end
Expand Down
1 change: 1 addition & 0 deletions activerecord/test/cases/migration/compatibility_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,7 @@ def migrate(x)
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
Expand Down