drift/examples/migrations_example
Moshe Dicker 6a693a9016 rebuild, format, and dart fix 2024-04-11 11:15:13 -04:00
..
drift_migrations Add tests for Dart index 2023-09-14 18:21:14 +02:00
lib rebuild, format, and dart fix 2024-04-11 11:15:13 -04:00
test Don't generate manager code for old snapshots 2024-04-05 21:52:18 +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 Update to lints 3.0.0 2023-11-16 21:25:21 +01: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