You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 24, 2020. It is now read-only.
There's a known issue in Rails when using references in a migration and a non-integer primary key. When using something else, like a UUID, references simply ignores this and still generates a migration with integer primary keys. This obviously breaks implementation.
There are a few ways I can see of getting around this (not sure which, if any, work)
Detect app setting and using a migration template to include type: :uuid on the references lines
Add a command-line option to the generator to add the UUID option in the migration
Convince Rails maintainers that this is a bug and offer up a patch
The text was updated successfully, but these errors were encountered:
I have made the jump to uuid for most all of my projects and will put another +1 here. I completely understand if this was a one off table/pk in a rails app the generator should not be expected to understand its state and do a "normal" default to int (or big serial it is sounding like now). But when users are specifically setting the global config in rails to uuid default it seems silly that core does not respect that as the default.
A related issue here is hardcoding table.id as the default order insert. UUID obviously does not sort as expected for first, last and a ton of AR expectations. Currently the solution is to shove in orders on created_at or some other stable/sortable field. I am wondering how hard it would be to have rails systems that are globally set to use uuids default to created_at to ensure "expected" ordering happens out of convention over configuration in this case too.
Edited:
Lol somehow I jumped here from the rails issue tracker without realizing it. oops.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
There's a known issue in Rails when using
references
in a migration and a non-integer primary key. When using something else, like a UUID,references
simply ignores this and still generates a migration with integer primary keys. This obviously breaks implementation.There are a few ways I can see of getting around this (not sure which, if any, work)
type: :uuid
on thereferences
linesThe text was updated successfully, but these errors were encountered: