Sha256: 9ed7cdbf5c6c6e71fbf4374d7a44e13096701ca5311b92273e9072c42a089f08

Contents?: true

Size: 531 Bytes

Versions: 18

Compression:

Stored size: 531 Bytes

Contents

class FixProfiles < ActiveRecord::Migration
  # We got this migration wrong before. Easiest fix is to undo it, then reapply
  # correctly

  class User < ActiveRecord::Base
    include BareMigration
  end

  def self.up
    remove_column :users, :profile_id
    add_column :users, :profile_id, :integer
    admin_id = Profile.find_by_label('admin').id
    User.update_all("profile_id = #{admin_id}")
  end

  def self.down
    remove_column :users, :profile_id
    add_column :users, :profile_id, :integer, :default => 1
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
typo-5.5 db/migrate/066_fix_profiles.rb
typo-5.4.4 db/migrate/066_fix_profiles.rb
typo-5.4.3 db/migrate/066_fix_profiles.rb
typo-5.4.2 db/migrate/066_fix_profiles.rb
typo-5.4.1 db/migrate/066_fix_profiles.rb
typo-5.4 db/migrate/066_fix_profiles.rb
typo-5.0.2 db/migrate/066_fix_profiles.rb
typo-5.0.1 db/migrate/066_fix_profiles.rb
typo-5.0.3.98.1 db/migrate/066_fix_profiles.rb
typo-5.0.3.98 db/migrate/066_fix_profiles.rb
typo-5.1.1 db/migrate/066_fix_profiles.rb
typo-5.1.2 db/migrate/066_fix_profiles.rb
typo-5.1.3 db/migrate/066_fix_profiles.rb
typo-5.1 db/migrate/066_fix_profiles.rb
typo-5.1.98 db/migrate/066_fix_profiles.rb
typo-5.2.98 db/migrate/066_fix_profiles.rb
typo-5.2 db/migrate/066_fix_profiles.rb
typo-5.3 db/migrate/066_fix_profiles.rb