SqlMigrationGenerator class
Translates a SchemaMigration into SQL statements for a given dialect.
Mapping:
| Operation | SQL |
|---|---|
add (defaultValue) |
ALTER TABLE t ADD COLUMN c <type> DEFAULT v |
add (sqlExpression backfill) |
... ADD COLUMN + UPDATE t SET c = expr |
rename |
ALTER TABLE t RENAME COLUMN a TO b |
remove |
ALTER TABLE t DROP COLUMN c |
transform (sqlExpression) |
UPDATE t SET c = expr |
row (sql: ...) |
the provided statements, verbatim |
The migration's SchemaMigration.sqlWhere scopes every generated UPDATE.
Operations that only exist as Dart closures (compute/transform/row
without their SQL counterpart) cannot be translated and raise a
MigrationException — as does a Dart-only SchemaMigration.where combined
with an UPDATE-producing operation, which would otherwise silently apply
to every row. SchemaMigration.entityType is ignored: SQL adapters store
one entity per table, so the table name is already the scope.
RENAME COLUMN and DROP COLUMN require SQLite 3.25+/3.35+; all current
Flutter/Dart sqlite bundles ship newer versions.
Constructors
- SqlMigrationGenerator({SqlDialect dialect = SqlDialect.sqlite})
-
const
Properties
- dialect → SqlDialect
-
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
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
statementsFor(
SchemaMigration migration, {required String table}) → List< String> -
Emits the ordered SQL statements for
migrationagainsttable. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited