Skip to content

Instantly share code, notes, and snippets.

@edwardloveall
Created March 7, 2015 00:09
Show Gist options
  • Save edwardloveall/8e5edd8c147c7421626c to your computer and use it in GitHub Desktop.
Save edwardloveall/8e5edd8c147c7421626c to your computer and use it in GitHub Desktop.
Rails: Migrate table from integer based primary keys to UUID
remove_column :table, :id, :primary_key
add_column :table, :id, :uuid, default: 'uuid_generate_v4()'
execute('ALTER TABLE table ADD PRIMARY KEY (id);')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment