drift/examples/migrations_example
Simon Binder 895ff52761 Add API for finegrained control for steps by steps 2023-08-19 22:39:38 +02:00
..
drift_migrations Extract custom Dart table constraints into schema 2022-12-16 15:34:07 +01:00
lib Add API for finegrained control for steps by steps 2023-08-19 22:39:38 +02:00
test Re-generate migration code 2023-08-02 18:43:28 +02:00
README.md Add step-by-step migration API 2023-07-01 16:41:22 +02:00
analysis_options.yaml Migrate to `package:lints` 2022-08-13 23:33:05 +02:00
build.yaml Make `generate_connect_constructor` the default 2023-01-28 16:14:27 +01:00
pubspec.yaml Start with generator for all schema versions 2023-06-28 15:54:32 +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 drift_migrations/

Generating test code

Run

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

Since we're using the step-by-step generator to make writing migrations easier, this command is used to generate a helper file in lib/:

dart run drift_dev schema steps drift_migrations/ lib/src/versions.dart