# frozen_string_literal: true

class GiveNamesToImportedAppearanceReleases < ActiveRecord::DataMigration
  def up
    AppearanceRelease.where(person_first_name: nil).each do |ar|
      contract_no = AppearanceRelease.random_contract_number.to_s
      if ar.person_photo.attached?
        ar.update(person_first_name: I18n.t('appearance_releases.shared.imported_appearance_release_headshot_name'), person_last_name: contract_no)
      else
        ar.update(person_first_name: I18n.t('appearance_releases.shared.imported_appearance_release_contract_name'), person_last_name: contract_no)
      end
    end
  end
end
