Migrator class final
Provides methods for generating SQL statements used to create, alter, or drop elements in a database.
An instance of Migrator is created by drift internally to run the migrations declared with a MigrationStrategy on your database class.
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_devthat 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(
GeneratedTable< Object, GeneratedTable< table, TableColumn<Object, dynamic> >Object> column) → Future<void> - Adds the given column to the specified table.
-
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.
-
createIndex(
Index index) → Future< void> -
Executes a
CREATE INDEXstatement to create theindex. -
createTable(
GeneratedTable< Object, GeneratedTable< table) → Future<Object, dynamic> >void> - Creates the given table if it doesn't exist.
-
createTrigger(
Trigger trigger) → Future< void> -
Executes the
CREATE TRIGGERstatement that created thetrigger. -
createView(
GeneratedView< Object, GeneratedView< view) → Future<Object, dynamic> >void> - Creates the given view if it doesn't exist.
-
deleteTable(
String name) → Future< void> -
Deletes the table with the given name. Note that this function does not
escape the
nameparameter. -
drop(
DatabaseSchemaEntity entity) → Future< void> - Drops a table, trigger or index.
-
dropColumn(
GeneratedTable< Object, GeneratedTable< table, String column) → Future<Object, dynamic> >void> -
Attempts to alter
tableto drop thecolumn. -
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(
GeneratedTable< Object, GeneratedTable< table, String oldName, TableColumn<Object, dynamic> >Object> column) → Future<void> -
Changes the name of a column in a
table. -
renameTable(
GeneratedTable< Object, GeneratedTable< table, String oldName) → Future<Object, dynamic> >void> -
Changes the
tablename fromoldNameto the current GeneratedTable.entityName. -
runMigrationSteps(
{required int from, required int to, required MigrationStepWithVersion steps}) → Future< void> -
Allows customizing step-by-step migrations (like the
OnUpgradecallback returned by the generatedstepByStepfunction) by invoking thestepsfunction for each intermediate schema version fromfromuntiltois reached. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited