Skip to content

Conversation

@j4rs
Copy link
Contributor

@j4rs j4rs commented Dec 10, 2025

Summary

  • Fixed false positive warning when using add_reference with foreign_key: { validate: false }
  • Previously, this would incorrectly warn "Adding a foreign key blocks writes on both tables" even though validate: false makes it safe
  • The fix aligns check_add_reference with check_add_foreign_key, which already handles validate: false correctly

Example

add_reference :users, :country_order,
              foreign_key: { to_table: :orders, validate: false },
              index: { algorithm: :concurrently }
  • Added test case test_foreign_key_validate_false
  • All existing tests pass (203 runs, 0 failures)
  • Updated CHANGELOG

j4rs added 2 commits December 10, 2025 10:00
…lse }

When using `add_reference` with `foreign_key: { validate: false }`, the
check incorrectly warns that "Adding a foreign key blocks writes on both
tables" even though `validate: false` makes it safe.

The fix updates `check_add_reference` to inspect whether the foreign_key
option contains `validate: false`, similar to how `check_add_foreign_key`
already handles this case.
@ankane
Copy link
Owner

ankane commented Dec 10, 2025

Hi @j4rs, thanks for the PR. The code looks good, but please remove the version bump and changelog date.

@j4rs j4rs force-pushed the add-validate-option-to-add-reference-foreign-key branch from bcee50b to 4a33d40 Compare December 10, 2025 20:46
@ankane ankane merged commit ae0bb2c into ankane:master Dec 10, 2025
@ankane
Copy link
Owner

ankane commented Dec 10, 2025

Great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants