drift/extras/migrations_example
Simon Binder 05d8406f4a
Fix migration example, test it in CI
2022-01-19 19:55:19 +01:00
..
drift_migrations Accept drift-named schema files 2021-10-14 21:44:44 +02:00
lib Fix migration example, test it in CI 2022-01-19 19:55:19 +01:00
test Make database of tables accessible for Dart API 2022-01-18 21:50:51 +01:00
README.md Fix migration example, test it in CI 2022-01-19 19:55:19 +01:00
analysis_options.yaml Adapt excludes in analysis options 2021-05-15 10:42:15 +02:00
build.yaml Migrate migration example to drift 2021-10-09 17:10:34 +02:00
pubspec.yaml Migrate migration example to drift 2021-10-09 17:10:34 +02:00

README.md

Example to demonstrate tests for schema migrations.

See test/migration_test.dart on how to use the generated verification code.

Workflow

Schema changes

After adapting a schema and incrementing the schemaVersion in the database, run

dart run drift_dev schema dump lib/database.dart moor_migrations/moor_schema_v2.json

Replace _v2 with the current schemaVersion.

Generating test code

Run

dart run drift_dev schema generate drift_migrations/ test/generated/ --data-classes --companions

We're also using test code inside lib/ to run migrations with older definitions of tables. This isn't required for all migrations, but can be useful in some cases.

dart run drift_dev schema generate drift_migrations/ lib/src/generated