-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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
Set active_record config for always creating uuids in generators #21762
Conversation
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @sgrif (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
This has falling tests |
@sgrif Thanks for the heads up. Tests passing. I'm pretty unfamiliar with the AR/Railties code, but I think I figured out how these generators work (kinda). I left the |
@@ -221,6 +221,16 @@ def test_create_table_migration | |||
end | |||
end | |||
|
|||
def test_add_uuid_to_create_table_migration | |||
Rails.application.config.active_record.primary_key = :uuid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to set this back to the old value at the end of this test?
Can you squash and rebase after addressing that comment? This will need a changelog entry as well. |
@sgrif Done. I'll watch the tests and let you know once it's all green... |
Thanks. I'm going through the backlog so you won't be able to keep up with the merge conflicts I think. Just ping me once the tests are green and I'll merge manually. |
@sgrif All checks passed. Merge conflict. :) |
Set active_record config for always creating uuids in generators
`id: :serial` is added because `id: :uuid` support was introduced. rails/rails#21762 `using: :btree` was redundant rails/rails#27981 Standardaized column spacing was removed to avoid diffs about aligining columns. rails/rails@df84e98#r22545295 ```diff - t.string "zipcode", limit: 5 + t.string "zipcode", limit: 5 + t.string "extra_information", limit: 255 ```
UUID's are awesome (and they improve performance). I want them everywhere, but it's annoying to have to modify my DB migrations every time. I wish I could make an application config to force the generators to always add
id: :uuid
whenever I create a table.Throw this in your
application.rb
file......and
id: :uuid
will be added to everycreate_table
generation: