class DestroyNonExistingGitHubUsers < ActiveRecord::Migration[5.1]
  def up
    unless ENV['RAILS_ENV'] == 'development'
      User.find_each do |user|
        if user.github_id == nil
          puts "removing user #{user.id} from database"
          user.destroy
        end
      end
    end
  end
end

class DestroyNonExistingGitHubUsers < ActiveRecord::Migration[5.1]
  def up
    unless ENV['RAILS_ENV'] == 'development'
      User.where(github_id: nil).destroy_all.each do |user|
        puts "removed user #{user.id} from database"
      end
    end
  end
end

Update migration; Never underestimate a 10 seconds win :-)
Update migration; Never underestimate a 10 seconds win :-)
