Somebody wrote a patch for Postgres UUID support in Rails. It was accepted and is available in edge.
https://github.com/rails/rails/pull/6713 On Thursday, January 10, 2013 12:00:39 PM UTC-7, Matthew Thorley wrote: > > Did anything ever become of this? > > I'm solving this same problem now and wondering whether I'm duplicating > some one else's effort. > > The approach I am taking is to writing a Rails extension that changes the > default behavior for all migrations, in a way that all models get an id > primary key that is type uuid and set by the database. > > I'm doing it in a Postgres specific way. > > On Monday, August 13, 2012 3:40:57 PM UTC-6, Aaron Patterson wrote: >> >> On Mon, Aug 13, 2012 at 01:55:41PM -0700, Chris Lloyd wrote: >> > Aaron, as you mention it's pretty easy easy to do this already, but >> it's >> > off the beaten path. On 3.2.6 I've included the postgres_ext gem to >> handle >> > UUID types in Postgres correctly. Migrations/models are also >> > easy: https://gist.github.com/3344006 >> >> I'd rather we do creation like this: >> >> CREATE TABLE x ( >> id uuid PRIMARY KEY DEFAULT uuid_generate_v4(), >> y integer >> ); >> >> Then a model with uuid primary keys should act the same as one using >> auto incrementing keys. IIRC, there is code in AR that depends on the >> database generating the record's ID. If the DB generated the uuid, >> everything should Just Work(tm) (I think). >> >> > So far everything works A-OK. It just seems as though it would be nicer >> > with some syntax in the migration. Perhaps `create_table(:foos, :id => >> > :uuid)`? >> >> Can we just modify the migration code to use the above form of >> CREATE TABLE? >> >> -- >> Aaron Patterson >> http://tenderlovemaking.com/ >> > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/ak-i7ldqNQIJ. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
