<!-- # hard line break macro for HTML -->

# fiftyone.migrations

* [fiftyone.migrations.runner](fiftyone.migrations.runner.md)
  * [`Version()`](fiftyone.migrations.runner.md#fiftyone.migrations.runner.Version)
  * [`get_database_revision()`](fiftyone.migrations.runner.md#fiftyone.migrations.runner.get_database_revision)
  * [`get_dataset_revision()`](fiftyone.migrations.runner.md#fiftyone.migrations.runner.get_dataset_revision)
  * [`get_datasets_revisions()`](fiftyone.migrations.runner.md#fiftyone.migrations.runner.get_datasets_revisions)
  * [`migrate_all()`](fiftyone.migrations.runner.md#fiftyone.migrations.runner.migrate_all)
  * [`migrate_database_if_necessary()`](fiftyone.migrations.runner.md#fiftyone.migrations.runner.migrate_database_if_necessary)
  * [`needs_migration()`](fiftyone.migrations.runner.md#fiftyone.migrations.runner.needs_migration)
  * [`migrate_dataset_if_necessary()`](fiftyone.migrations.runner.md#fiftyone.migrations.runner.migrate_dataset_if_necessary)
  * [`MigrationRunner`](fiftyone.migrations.runner.md#fiftyone.migrations.runner.MigrationRunner)
    * [`MigrationRunner.head`](fiftyone.migrations.runner.md#fiftyone.migrations.runner.MigrationRunner.head)
    * [`MigrationRunner.destination`](fiftyone.migrations.runner.md#fiftyone.migrations.runner.MigrationRunner.destination)
    * [`MigrationRunner.direction`](fiftyone.migrations.runner.md#fiftyone.migrations.runner.MigrationRunner.direction)
    * [`MigrationRunner.has_revisions`](fiftyone.migrations.runner.md#fiftyone.migrations.runner.MigrationRunner.has_revisions)
    * [`MigrationRunner.has_admin_revisions`](fiftyone.migrations.runner.md#fiftyone.migrations.runner.MigrationRunner.has_admin_revisions)
    * [`MigrationRunner.revisions`](fiftyone.migrations.runner.md#fiftyone.migrations.runner.MigrationRunner.revisions)
    * [`MigrationRunner.admin_revisions`](fiftyone.migrations.runner.md#fiftyone.migrations.runner.MigrationRunner.admin_revisions)
    * [`MigrationRunner.run()`](fiftyone.migrations.runner.md#fiftyone.migrations.runner.MigrationRunner.run)
    * [`MigrationRunner.run_admin()`](fiftyone.migrations.runner.md#fiftyone.migrations.runner.MigrationRunner.run_admin)

## Module contents

FiftyOne’s migration interface.

Copyright 2017-2026, Voxel51, Inc.
<br/>
[voxel51.com](https://voxel51.com/)
<br/>
<br/>

**Functions:**

| [`get_database_revision`](#fiftyone.migrations.get_database_revision)()                                   | Gets the current revision of the database.                                                                   |
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------|
| [`get_dataset_revision`](#fiftyone.migrations.get_dataset_revision)(name)                                 | Gets the current revision of the given dataset.                                                              |
| [`get_datasets_revisions`](#fiftyone.migrations.get_datasets_revisions)()                                 | Gets the current revision of all datasets.                                                                   |
| [`migrate_all`](#fiftyone.migrations.migrate_all)([destination, error_level, verbose])                    | Migrates the database and all datasets to the specified destination revision.                                |
| [`migrate_database_if_necessary`](#fiftyone.migrations.migrate_database_if_necessary)([destination, ...]) | Migrates the database to the specified revision, if necessary.                                               |
| [`migrate_dataset_if_necessary`](#fiftyone.migrations.migrate_dataset_if_necessary)(name[, ...])          | Migrates the dataset from its current revision to the specified destination revision.                        |
| [`needs_migration`](#fiftyone.migrations.needs_migration)([name, head, destination])                      | Determines whether a dataset requires a migration in order to be used in the specified destination revision. |

### fiftyone.migrations.get_database_revision()

Gets the current revision of the database.

* **Returns:**
  the database revision string

### fiftyone.migrations.get_dataset_revision(name)

Gets the current revision of the given dataset.

* **Parameters:**
  **name** – the name of the dataset
* **Returns:**
  the dataset revision string

### fiftyone.migrations.get_datasets_revisions()

Gets the current revision of all datasets.

* **Returns:**
  a dictionary mapping dataset names to their revision strings

### fiftyone.migrations.migrate_all(destination=None, error_level=0, verbose=False)

Migrates the database and all datasets to the specified destination
revision.

If `fiftyone.config.database_admin` is `False` and no `destination`
is provided, the database and each dataset will only be migrated if their
current versions are not compatible with the client’s version.

* **Parameters:**
  * **destination** (*None*) – the destination revision. By default, the
    `fiftyone` client version is used
  * **error_level** (*0*) – 

    the error level to use if an individual dataset cannot
    be migrated. Valid values are:
    - 0: raise error if a dataset cannot be migrated
    - 1: log warning if a dataset cannot be migrated
    - 2: ignore datasets that cannot be migrated
  * **verbose** (*False*) – whether to log incremental migrations that are run

### fiftyone.migrations.migrate_database_if_necessary(destination=None, verbose=False, config=None)

Migrates the database to the specified revision, if necessary.

If `fiftyone.config.database_admin` is `False` and no `destination`
is provided, the database will only be migrated if its current version is
not compatible with the client’s version.

* **Parameters:**
  * **destination** (*None*) – the destination revision. By default, the
    `fiftyone` client version is used
  * **verbose** (*False*) – whether to log incremental migrations that are run
  * **config** (*None*) – an optional `DatabaseConfigDocument`. By default,
    DB config is pulled from the database.

### fiftyone.migrations.migrate_dataset_if_necessary(name, destination=None, error_level=0, verbose=False)

Migrates the dataset from its current revision to the specified
destination revision.

If `fiftyone.config.database_admin` is `False` and no `destination`
is provided, the dataset will only be migrated if its current version is
not compatible with the client’s version.

* **Parameters:**
  * **name** – the name of the dataset
  * **destination** (*None*) – the destination revision. By default, the current
    database version is used
  * **error_level** (*0*) – 

    the error level to use. Valid values are:
    - 0: raise error if the dataset cannot be migrated
    - 1: log warning if the dataset cannot be migrated
    - 2: ignore datasets that cannot be migrated
  * **verbose** (*False*) – whether to log incremental migrations that are run

### fiftyone.migrations.needs_migration(name=None, head=None, destination=None)

Determines whether a dataset requires a migration in order to be used in
the specified destination revision.

To use this method, specify either the `name` of an existing dataset or
provide the `head` revision of the dataset.

If `fiftyone.config.database_admin` is `False` and no `destination`
is provided, a dataset will be deemed to require no migration if its
current version if compatible with the client’s version.

* **Parameters:**
  * **name** (*None*) – the name of the dataset
  * **head** (*None*) – the current revision of the dataset
  * **destination** (*None*) – the destination revision. By default, the current
    database version is used
* **Returns:**
  True/False
