Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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