Skip to content
This repository has been archived by the owner on Nov 24, 2020. It is now read-only.

Change generator to respect primary key setting #2

Open
lleger opened this issue Aug 23, 2016 · 1 comment
Open

Change generator to respect primary key setting #2

lleger opened this issue Aug 23, 2016 · 1 comment

Comments

@lleger
Copy link
Member

lleger commented Aug 23, 2016

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)

  1. Detect app setting and using a migration template to include type: :uuid on the references lines
  2. Add a command-line option to the generator to add the UUID option in the migration
  3. Convince Rails maintainers that this is a bug and offer up a patch
@wadestuart
Copy link

wadestuart commented Sep 27, 2016

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 free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants