public class

RoomDatabase.MigrationContainer

extends java.lang.Object

 java.lang.Object

↳androidx.room.RoomDatabase.MigrationContainer

Overview

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

Summary

Constructors
publicMigrationContainer()

Methods
public voidaddMigrations(java.util.List<Migration> migrations)

Adds the given migrations to the list of available migrations.

public voidaddMigrations(Migration migrations[])

Adds the given migrations to the list of available migrations.

public java.util.List<Migration>findMigrationPath(int start, int end)

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

public java.util.Map<java.lang.Integer, java.util.Map>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).

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public MigrationContainer()

Methods

public void addMigrations(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:

migrations: List of available migrations.

public void addMigrations(java.util.List<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:

migrations: List of available migrations.

public java.util.Map<java.lang.Integer, java.util.Map> 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:

Map of migrations keyed by the start version

public java.util.List<Migration> findMigrationPath(int start, int end)

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

Parameters:

start: The current database version
end: The target database version

Returns:

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.