# RoomDatabase.MigrationContainer

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

*** ** * ** ***

Common/AllAndroid/JVMNative/C/iOSJavaScript
- Cmn

  ```
  class RoomDatabase.MigrationContainer
  ```
- android

  ```
  open class RoomDatabase.MigrationContainer
  ```

*** ** * ** ***

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/kotlin/androidx/room/RoomDatabase.MigrationContainer#MigrationContainer()()` | android |
| `https://developer.android.com/reference/kotlin/androidx/room/RoomDatabase.MigrationContainer#MigrationContainer()()` | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/room/RoomDatabase.MigrationContainer#MigrationContainer()()` | N |

| ### Public functions |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/room/RoomDatabase.MigrationContainer#addMigrations(kotlin.collections.List)(migrations: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/room/migration/Migration>)` Adds the given migrations to the list of available migrations. | Cmn android N |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/room/RoomDatabase.MigrationContainer#addMigrations(kotlin.Array)(vararg migrations: https://developer.android.com/reference/kotlin/androidx/room/migration/Migration)` Adds the given migrations to the list of available migrations. | android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/room/RoomDatabase.MigrationContainer#contains(kotlin.Int,kotlin.Int)(startVersion: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, endVersion: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Indicates if the given migration is contained within the `https://developer.android.com/reference/kotlin/androidx/room/RoomDatabase.MigrationContainer` based on its start-end versions. | Cmn android N |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/room/migration/Migration>?` | `https://developer.android.com/reference/kotlin/androidx/room/RoomDatabase.MigrationContainer#findMigrationPath(kotlin.Int,kotlin.Int)(start: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, end: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Finds the list of migrations that should be run to move from `start` version to `end` version. | android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, https://developer.android.com/reference/kotlin/androidx/room/migration/Migration>>` | `https://developer.android.com/reference/kotlin/androidx/room/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). | Cmn android N |

## Public constructors

### MigrationContainer

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

```
MigrationContainer()
```

### MigrationContainer

Cmn Added in [2.0.0](https://developer.android.com/jetpack/androidx/releases/room#2.0.0)

```
MigrationContainer()
```

### MigrationContainer

N Added in [2.0.0](https://developer.android.com/jetpack/androidx/releases/room#2.0.0)

```
MigrationContainer()
```

## Public functions

### addMigrations

Cmn android N Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/room#2.4.0)

```
fun addMigrations(migrations: List<Migration>): Unit
```

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 |
|---|---|
| `migrations: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/room/migration/Migration>` | List of available migrations. |

### addMigrations

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

```
open fun addMigrations(vararg migrations: Migration): Unit
```

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 |
|---|---|
| `vararg migrations: https://developer.android.com/reference/kotlin/androidx/room/migration/Migration` | List of available migrations. |

### contains

Cmn android N Added in [2.5.0](https://developer.android.com/jetpack/androidx/releases/room#2.5.0)

```
fun contains(startVersion: Int, endVersion: Int): Boolean
```

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

| Parameters |
|---|---|
| `startVersion: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Start version of the migration. |
| `endVersion: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | End version of the migration |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | True if it contains a migration with the same start-end version, false otherwise. |

### findMigrationPath

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

```
open fun findMigrationPath(start: Int, end: Int): List<Migration>?
```

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

| Parameters |
|---|---|
| `start: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The current database version |
| `end: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The target database version |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/room/migration/Migration>?` | An ordered list of `https://developer.android.com/reference/kotlin/androidx/room/migration/Migration` objects that should be run to migrate between the given versions. If a migration path cannot be found, returns `null`. |

### getMigrations

Cmn android N Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/room#2.4.0)

```
fun getMigrations(): Map<Int, Map<Int, Migration>>
```

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://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, https://developer.android.com/reference/kotlin/androidx/room/migration/Migration>>` | Map of migrations keyed by the start version |