-
-
Notifications
You must be signed in to change notification settings - Fork 263
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
Rails/CreateTableWithTimestamps shouldn't warn when id: false is used #34
Comments
I think it's still useful to have timestamps on a join table, even if just for troubleshooting. |
I disagree with @andyw8, because it's seems useless for habtm tables. My opinion is to have only Therefore I totally agree with @connorshea that this is false positive |
…lse` and not include `timestamps` Fixes rubocop#34. This PR allows `CreateTableWithTimestamps` when using `id: false` and not include `timestamps`. There are design arguments for both allowing and disallowing migration file has `timestamps` when `id: false` (join table) . For the following reasons, allow it when `id: false`: For example, when running `bin/rails g migration create_articles`, the migration file containing `timestamps` is created by default. Perhaps editing `id: false` and removing `timestamps` will be intentional. On the other hand, if it is not intentionally deleted, it will remain. So I think that it is possible to allow the behavior that `timestamps` is not written for `id: false`. This emphasizes respecting user's editing intentions.
…for_id_false [Fix #34] Allow `CreateTableWithTimestamps` when using `id: false` and not include `timestamps`
Thank you Koichi! |
In migrations you can create a join table like so:
But
Rails/CreateTableWithTimestamps
will warn about this code because the table is being created without timestamps. Join tables shouldn't have timestamps, so this is a false positive.https://guides.rubyonrails.org/association_basics.html#creating-join-tables-for-has-and-belongs-to-many-associations
The text was updated successfully, but these errors were encountered: