ref: master
db/migrate/20131121162641_remove_orphan_profiles.rb
1 2 3 4 5 6 7 8 9 10 |
class RemoveOrphanProfiles < ActiveRecord::Migration def self.up profiles = Profile.joins('LEFT JOIN environments ON profiles.environment_id=environments.id').where('environments.id IS NULL') profiles.map(&:destroy) end def self.down say 'This migration can not be reverted.' end end |