namespace :services do
  desc "Move discontinued at from discontinued_services to services"
  task move_discontinued_at_to_services: :environment do
    services = Service.all
    puts "Going to update each service discontinued at"

    ActiveRecord::Base.transaction do
      services.each do |service|
        if service.discontinued_services.exists?
          service.discontinued_at = service.discontinued_services.first.discontinued_at
          service.discontinued_by_educator_id = service.discontinued_services.first.recorded_by_educator_id
          service.save
          puts "saving service"
        end
      end
    end

    puts " All done now!"
  end
end

namespace :services do
  desc "Move discontinued at from discontinued_services to services"
  task move_discontinued_at_to_services: :environment do
    services = Service.all
    puts "Going to update each service discontinued at"

    ActiveRecord::Base.transaction do
      services.each do |service|
        if service.discontinued_services.exists?
          service.discontinued_at = service.discontinued_services.first.discontinued_at
          service.discontinued_by_educator_id = service.discontinued_services.first.recorded_by_educator_id
          service.save!
          puts "saving service"
        end
      end
    end

    puts " All done now!"
  end
end

Change discontinued services migration to fail noisily
Change discontinued services migration to fail noisily

+ Good improvement opportunity that @kevinrobinson spotted -- if any of the services in this migration fail to save, they'll fail silently and we'd never know. Switching to use the bang version of save so that the migration will fail if any of the services fail to update. After this merges I'll re-run the migration
