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

Idea: For Rails 7.1, error when there are foreign keys with validate: false #169

Open
jdufresne opened this issue Jan 19, 2024 · 2 comments

Comments

@jdufresne
Copy link
Contributor

jdufresne commented Jan 19, 2024

Rails 7.1 added the feature to record validate in schema.rb, see upstream PR: rails/rails#46339

My proposal is that active_record_doctor emits an error when validate: false exists. In my experience, this is normally a "code smell" that something went wrong with migrations and they are incomplete.

I most often use validate: false on the advice of strong_migrations for a zero downtime schema change, but the validation is resolved once all migration riles run. Their docs are at: https://github.com/ankane/strong_migrations#adding-a-foreign-key

@fatkodima
Copy link
Contributor

These will be false positives most of the time, because the next step in migrations will be validation for these and the validate will be removed then. So it will stay not a long time in the schema.rb and lead to violations and disabling of it in the gems config file.

@jdufresne
Copy link
Contributor Author

These will be false positives most of the time, because the next step in migrations will be validation for these and the validate will be removed then. So it will stay not a long time in the schema.rb and lead to violations and disabling of it in the gems config file.

In my experience, these steps come together within the same PR, just as separate migration files. So at CI time, there will not be a false positive.

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

No branches or pull requests

2 participants