Skip to content

Instantly share code, notes, and snippets.

@doxavore
Forked from chrislloyd/migration.rb
Created December 14, 2012 01:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doxavore/4281725 to your computer and use it in GitHub Desktop.
Save doxavore/4281725 to your computer and use it in GitHub Desktop.
create_table :users, id: false do |t|
t.uuid :id, primary: true, null: false
# ...
end
require 'uuid'
module UUIDPrimaryKey
extend ActiveSupport::Concern
included do |klass|
klass.primary_key = :id
klass.before_create do
self.id = UUID.generate
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment