class ViewModel::DownMigrator

specific version requested by the client.
down migrations find a reverse path from the current schema version to the

def migrate_viewmodel!(view_name, source_version, view_hash, references)

def migrate_viewmodel!(view_name, source_version, view_hash, references)
  plan = fetch_plan(view_name)
  return false unless plan
  # In a serialized output, the source version should always be the present
  # and the current version, unless already modified by a parent migration
  return false if source_version == plan.required_version
  # If a parent migration has already partially migrated us to an
  # intermediate version, we need to construct a new path to the required
  # version.
  if source_version == plan.current_version
    path = plan.path
  elsif view_hash[ViewModel::MIGRATED_ATTRIBUTE] &&
        source_version > plan.required_version &&
        source_version < plan.current_version
    path = plan.viewmodel_class.migration_path(from: plan.required_version, to: source_version)
  else
    raise ViewModel::Migration::UnspecifiedVersionError.new(view_name, source_version)
  end
  path.reverse_each do |migration|
    migration.down(view_hash, references)
  end
  view_hash[ViewModel::VERSION_ATTRIBUTE] = plan.required_version
  true
end