class MoveMusicReleaseConfirmationsToAudioConfirmations < ActiveRecord::DataMigration
  def up
    say "Moving Music Release Confirmations to Audio Confirmations"

    VideoReleaseConfirmation.where(releasable_type: "MusicRelease").find_each do |music_release_confirmation|
      AudioConfirmation.create!(
        video_id: music_release_confirmation.video_id,
        channel: music_release_confirmation.channel,
        timecode_in: music_release_confirmation.timecode_in,
        timecode_out: music_release_confirmation.timecode_out,
        duration: music_release_confirmation.duration,
        source_file_name: music_release_confirmation.source_file_name,
        clip_name: music_release_confirmation.clip_name,
        description: music_release_confirmation.description,
        time_elapsed: music_release_confirmation.time_elapsed,
        music_type: music_release_confirmation.music_type,
        music_category: music_release_confirmation.music_category,
        composer_info: music_release_confirmation.releasable.composers.map { |composer| "#{composer.name}, #{composer.affiliation}, #{composer.percentage}%" }.join("|"),
        publisher_info: music_release_confirmation.releasable.publishers.map { |publisher| "#{publisher.name}, #{publisher.affiliation}, #{publisher.percentage}%" }.join("|"),
        catalog: "",
        title: "",
        time_elapsed: music_release_confirmation.time_elapsed,
      )
    end

    say "Done."
  end
end