Quantcast
Channel: Hacker News 50
Viewing all articles
Browse latest Browse all 9433

Rails 4 UUID primary keys with PostgreSQL

$
0
0

Comments:"Rails 4 UUID primary keys with PostgreSQL"

URL:http://labria.github.io/2013/04/27/rails-4-uuid-primary-keys-with-postgresql/


UPD: See my second, more detailed post about the matter.

Aaron recently added uuid primary key support to Rails4 edge. To try it in your app simply create a migration like this:

create_table:users,id:falsedo|t|t.primary_key:id,:uuidt.string:namet.timestampsend

Rails now automatically sets the default value to uuid_generate_v4() for the primary_key.

You’ll of course need to run CREATE EXTENSION "uuid-ossp"; in Postgres, either manually or with a migration via a execute statement.


Viewing all articles
Browse latest Browse all 9433

Trending Articles