Skip to content

Instantly share code, notes, and snippets.

View DaanVanVugt's full-sized avatar

Daan van Vugt DaanVanVugt

View GitHub Profile
@DaanVanVugt
DaanVanVugt / gist:c2b2161770b3282eb3ab
Created July 26, 2014 10:34
Migration code to move to unique ids
def generate_uuid(prefix, id)
UUIDTools::UUID.sha1_create(UUIDTools::UUID_OID_NAMESPACE, "#{prefix}-#{id}")
end
class TransformToUuids < ActiveRecord::Migration
def change
models = [Contact, User, Version]
models.each do |model|
# Create new column for uuid