Migrator class

Runs migrations declared by a MigrationStrategy.

Constructors

Migrator(GeneratedDatabase database, [VersionedSchema? _fixedVersion])
Used internally by drift when opening the database.

Properties

database GeneratedDatabase
The instance of the GeneratedDatabase class generated by drift_dev that this migrator is connected to.
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addColumn(TableInfo<Table, dynamic> table, GeneratedColumn<Object> column) Future<void>
Adds the given column to the specified table.
alterTable(TableMigration migration) Future<void>
Alter columns of an existing tabe.
create(DatabaseSchemaEntity entity) Future<void>
Creates the given entity, which can be a table, a view, a trigger, an index or an OnCreateQuery.
createAll() Future<void>
Creates all tables, triggers, views, indexes and everything else defined in the database, if they don't exist.
createAllTables() Future<void>
Creates all tables specified for the database, if they don't exist
createIndex(Index index) Future<void>
Executes a CREATE INDEX statement to create the index.
createTable(TableInfo<Table, dynamic> table) Future<void>
Creates the given table if it doesn't exist
createTrigger(Trigger trigger) Future<void>
Executes the CREATE TRIGGER statement that created the trigger.
createView(ViewInfo<HasResultSet, dynamic> view) Future<void>
Executes a CREATE VIEW statement to create the view.
deleteTable(String name) Future<void>
Deletes the table with the given name. Note that this function does not escape the name parameter.
drop(DatabaseSchemaEntity entity) Future<void>
Drops a table, trigger or index.
issueCustomQuery(String sql, [List? args]) Future<void>
Executes the custom query.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
recreateAllViews() Future<void>
Drops and re-creates all views known to the database.
renameColumn(TableInfo<Table, dynamic> table, String oldName, GeneratedColumn<Object> column) Future<void>
Changes the name of a column in a table.
renameTable(TableInfo<Table, dynamic> table, String oldName) Future<void>
Changes the table name from oldName to the current TableInfo.actualTableName.
runMigrationSteps({required int from, required int to, required MigrationStepWithVersion steps}) Future<void>
Allows customizing step-by-step migrations (like the OnUpgrade callback returned by the generated stepByStep function) by invoking the steps function for each intermediate schema version from from until to is reached.
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

stepByStepHelper({required MigrationStepWithVersion step}) OnUpgrade
A helper used by drift internally to implement the step-by-step migration feature.