Skip to content

Instantly share code, notes, and snippets.

@awesome
Forked from chrislloyd/migration.rb
Created September 30, 2012 05:39
Show Gist options
  • Save awesome/3805977 to your computer and use it in GitHub Desktop.
Save awesome/3805977 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