RoomDatabase.MigrationContainer
public final class RoomDatabase.MigrationContainer
A container to hold migrations. It also allows querying its contents to find migrations between two versions.
Summary
Public constructors |
|---|
Public methods |
|
|---|---|
void |
addMigrations(@NonNull List<@NonNull Migration> migrations)Adds the given migrations to the list of available migrations. |
void |
addMigrations(@NonNull Migration... migrations)Adds the given migrations to the list of available migrations. |
final boolean |
contains(int startVersion, int endVersion)Indicates if the given migration is contained within the |
List<@NonNull Migration> |
findMigrationPath(int start, int end)Finds the list of migrations that should be run to move from |
@NonNull Map<@NonNull Integer, @NonNull Map<@NonNull Integer, @NonNull 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). |
Public constructors
Public methods
addMigrations
public 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.
addMigrations
public 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.
contains
public final boolean contains(int startVersion, int endVersion)
Indicates if the given migration is contained within the 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
public 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 |