module ActiveRecord::Tasks::DatabaseTasks

def reconstruct_from_schema(db_config, format = ActiveRecord.schema_format, file = nil) # :nodoc:

:nodoc:
def reconstruct_from_schema(db_config, format = ActiveRecord.schema_format, file = nil) # :nodoc:
  file ||= schema_dump_path(db_config, format)
  check_schema_file(file) if file
  with_temporary_pool(db_config, clobber: true) do
    if schema_up_to_date?(db_config, format, file)
      truncate_tables(db_config) unless ENV["SKIP_TEST_DATABASE_TRUNCATE"]
    else
      purge(db_config)
      load_schema(db_config, format, file)
    end
  rescue ActiveRecord::NoDatabaseError
    create(db_config)
    load_schema(db_config, format, file)
  end
end