Sha256: a05fefaf7e314b7d68f2ba5d3e91b889c47cdbca0fb8b05f580cd9070fbbecc5
Contents?: true
Size: 644 Bytes
Versions: 6
Compression:
Stored size: 644 Bytes
Contents
class ReplaceProfileIdWithString < ActiveRecord::Migration class Profile < ActiveRecord::Base end class User < ActiveRecord::Base end def up add_column :users, :profile, :string User.reset_column_information User.find_each do |user| user.update_attribute(:profile, Profile.find(user.profile_id).label) end remove_column :users, :profile_id end def down add_column :users, :profile_id, :integer User.reset_column_information User.find_each do |user| user.update_attribute(:profile_id, Profile.find_by(label: user.profile).id) end remove_column :users, :profile end end
Version data entries
6 entries across 6 versions & 1 rubygems