# RoomDatabase.MigrationContainer

Artifact: [androidx.room3:room3-runtime](https://developer.android.com/jetpack/androidx/releases/room3) [View Source](https://cs.android.com/search?q=file:androidx/room3/RoomDatabase.+class:androidx.room3.RoomDatabase.MigrationContainer) Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

*** ** * ** ***


```
public final class RoomDatabase.MigrationContainer
```

<br />

*** ** * ** ***

A container to hold migrations. It also allows querying its contents to find migrations between two versions.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/room3/RoomDatabase.MigrationContainer#MigrationContainer()()` |
| `https://developer.android.com/reference/androidx/room3/RoomDatabase.MigrationContainer#MigrationContainer()()` |

| ### Public methods |
|---|---|
| `final void` | `https://developer.android.com/reference/androidx/room3/RoomDatabase.MigrationContainer#addMigrations(kotlin.collections.List)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/room3/migration/Migration> migrations)` Adds the given migrations to the list of available migrations. |
| `final void` | `https://developer.android.com/reference/androidx/room3/RoomDatabase.MigrationContainer#addMigrations(kotlin.Array)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/room3/migration/Migration... migrations)` Adds the given migrations to the list of available migrations. |
| `final boolean` | `https://developer.android.com/reference/androidx/room3/RoomDatabase.MigrationContainer#contains(kotlin.Int,kotlin.Int)(int startVersion, int endVersion)` Indicates if the given migration is contained within the `https://developer.android.com/reference/androidx/room3/RoomDatabase.MigrationContainer` based on its start-end versions. |
| `final https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/room3/migration/Migration>` | `https://developer.android.com/reference/androidx/room3/RoomDatabase.MigrationContainer#findMigrationPath(kotlin.Int,kotlin.Int)(int start, int end)` Finds the list of migrations that should be run to move from `start` version to `end` version. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Map.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Integer.html, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Map.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Integer.html, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/room3/migration/Migration>>` | `https://developer.android.com/reference/androidx/room3/RoomDatabase.MigrationContainer#getMigrations()()` Returns the map of available migrations where the key is the start version of the migration, and the value is a map of (end version -\> Migration). |

## Public constructors

### MigrationContainer

Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

```
public MigrationContainer()
```

### MigrationContainer

Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

```
public MigrationContainer()
```

## Public methods

### addMigrations

```
public final void addMigrations(@NonNull List<@NonNull Migration> migrations)
```

Adds the given migrations to the list of available migrations. If 2 migrations have the same start-end versions, the latter migration overrides the previous one.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/room3/migration/Migration> migrations` | List of available migrations. |

### addMigrations

Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

```
public final void addMigrations(@NonNull Migration... migrations)
```

Adds the given migrations to the list of available migrations. If 2 migrations have the same start-end versions, the latter migration overrides the previous one.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/room3/migration/Migration... migrations` | List of available migrations. |

### contains

Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

```
public final boolean contains(int startVersion, int endVersion)
```

Indicates if the given migration is contained within the `https://developer.android.com/reference/androidx/room3/RoomDatabase.MigrationContainer` based on its start-end versions.

| Parameters |
|---|---|
| `int startVersion` | Start version of the migration. |
| `int endVersion` | End version of the migration |

| Returns |
|---|---|
| `boolean` | True if it contains a migration with the same start-end version, false otherwise. |

### findMigrationPath

Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

```
public final List<@NonNull Migration> findMigrationPath(int start, int end)
```

Finds the list of migrations that should be run to move from `start` version to `end` version.

| Parameters |
|---|---|
| `int start` | The current database version |
| `int end` | The target database version |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/room3/migration/Migration>` | An ordered list of `https://developer.android.com/reference/androidx/room3/migration/Migration` objects that should be run to migrate between the given versions. If a migration path cannot be found, returns `null`. |

### getMigrations

Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

```
public final @NonNull Map<@NonNull Integer, @NonNull Map<@NonNull Integer, @NonNull Migration>> getMigrations()
```

Returns the map of available migrations where the key is the start version of the migration, and the value is a map of (end version -\> Migration).

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Map.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Integer.html, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Map.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Integer.html, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/room3/migration/Migration>>` | Map of migrations keyed by the start version |