migrateAndValidate abstract method
- GeneratedDatabase db,
- int expectedVersion, {
- ValidationOptions options = const ValidationOptions(),
- @Deprecated('Use field in ValidationOptions instead') bool? validateDropped,
Runs a schema migration and verifies that it transforms the database into a correct state.
This involves opening the db
and calling its
GeneratedDatabase.migration
to migrate it to the latest version.
Finally, the method will read from sqlite_schema
to verify that the
schema at runtime matches the expected schema version.
The future completes normally if the schema migration succeeds and brings the database into the expected schema. If the comparison fails, a SchemaMismatch exception will be thrown.
The ValidationOptions can be used to make the schema validation more strict (e.g. by enabling ValidationOptions.validateDropped to ensure that no old tables continue to exist if they're not referenced in the new schema) or more lenient (e.g. by disabling ValidationOptions.validateColumnConstraints).
Implementation
Future<void> migrateAndValidate(
GeneratedDatabase db,
int expectedVersion, {
ValidationOptions options = const ValidationOptions(),
@Deprecated('Use field in ValidationOptions instead') bool? validateDropped,
});