RoomDatabase.MigrationContainer



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

Summary

Public constructors

android
Cmn
N

Public functions

Unit

Adds the given migrations to the list of available migrations.

Cmn
android
N
open Unit
addMigrations(vararg migrations: Migration)

Adds the given migrations to the list of available migrations.

android
Boolean
contains(startVersion: Int, endVersion: Int)

Indicates if the given migration is contained within the MigrationContainer based on its start-end versions.

Cmn
android
N
open List<Migration>?
findMigrationPath(start: Int, end: Int)

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

android
Map<IntMap<IntMigration>>

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

MigrationContainer()

MigrationContainer

MigrationContainer()

MigrationContainer

MigrationContainer()

Public functions

addMigrations

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: List<Migration>

List of available migrations.

addMigrations

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: Migration

List of available migrations.

contains

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

Indicates if the given migration is contained within the MigrationContainer based on its start-end versions.

Parameters
startVersion: Int

Start version of the migration.

endVersion: Int

End version of the migration

Returns
Boolean

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

findMigrationPath

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: Int

The current database version

end: Int

The target database version

Returns
List<Migration>?

An ordered list of Migration objects that should be run to migrate between the given versions. If a migration path cannot be found, returns null.

getMigrations

fun getMigrations(): Map<IntMap<IntMigration>>

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
Map<IntMap<IntMigration>>

Map of migrations keyed by the start version