MigrationStrategy class

: a version-tagged, callback-driven migration declaration. The version is the target schema version (not the number of migrations applied). On a fresh install the runner applies every migration whose version is <= this.version.

Constructors

MigrationStrategy({required int version, List<MigrationBase> migrations = const <MigrationBase>[], Future<void> onCreate(MigrationExecutor exec, int version)?, Future<void> onUpgrade(MigrationExecutor exec, int oldVersion, int newVersion)?, Future<void> onDowngrade(MigrationExecutor exec, int oldVersion, int newVersion)?, bool trackMigrations = true})
const

Properties

hashCode int
The hash code for this object.
no setterinherited
isImperative bool
: true when the strategy uses imperative callbacks (onCreate / onUpgrade / onDowngrade) and false when it uses the declarative migrations list. Computed once from the constructor arguments.
no setter
migrations List<MigrationBase>
: the full, ordered list of available migrations. The runner picks the subset to apply / rollback based on version and the database's current version.
final
onCreate Future<void> Function(MigrationExecutor exec, int version)?
: imperative-mode callback. Invoked once when the database is created for the first time. By default (in declarative mode) the runner applies every migration in migrations in order.
final
onDowngrade Future<void> Function(MigrationExecutor exec, int oldVersion, int newVersion)?
: imperative-mode callback. Invoked when the database is being downgraded from oldVersion (newV < oldV). The user typically branches on oldV:
final
onUpgrade Future<void> Function(MigrationExecutor exec, int oldVersion, int newVersion)?
: imperative-mode callback. Invoked when the database is being upgraded from oldVersion (0 ≤ oldV < newV). The user typically branches on oldV:
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
trackMigrations bool
: when true (default in declarative mode), the runner records each applied migration in the _d_rocket_migrations table. When false (default in imperative mode with onCreate / onUpgrade), the user is responsible for the table.
final
version int
: the target schema version. After running this strategy, the database is at this version.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited