Closed equivalent closed 5 years ago
class AddTokenToUsers < ActiveRecord::Migration
def change
enable_extension 'uuid-ossp'
add_column :users, :token, :uuid, default: 'uuid_generate_v4()'
end
end
ok after thinking about this this may not be the best approach for this gem. Core principle of the gem is the before_create
hook that is setting the random string to public_uid column (and we use ORM to support as many DB solutions).
So yes the uuid
coulumn is an option but it's more of a custom implementation to whoever wants it but it will lock the project only to one type of DB
And specially after implemetaion of SecureRandom.hex in v 1.3 this is not really needed https://github.com/equivalent/public_uid/issues/10
Think about how to implement UUID solution with this project
It is possible to do something like this:
(so we can create create custom string generator like this one https://github.com/equivalent/public_uid/blob/master/lib/public_uid/generators/range_string.rb%60 )
BUT rails 4 this should be automatic
So :thinking: how to merge this solution to public_uid project
Maybe just a readme note on UUID would be enough