class AddPersonFirstAndLastNameToReleases < ActiveRecord::Migration[6.0]
  RELEASES = [:acquired_media_releases, :appearance_releases, :location_releases, :material_releases, :music_releases, :talent_releases]

  def up
    RELEASES.each do |table_name|
      add_column(table_name, :person_first_name, :string)
      add_column(table_name, :person_last_name, :string)

      change_column(table_name, :person_name, :string, null: true)
      rename_column(table_name, :person_name, :person_name_old)
    end
  end

  def down
    RELEASES.each do |table_name|
      remove_column(table_name, :person_first_name, :string)
      remove_column(table_name, :person_last_name, :string)
      
      rename_column(table_name, :person_name_old, :person_name)
    end
  end
end
