drift/examples/migrations_example
Simon Binder d6e074e704
Fix `validateDatabaseSchema` in schema tests
2023-03-23 17:56:50 +01:00
..
drift_migrations Extract custom Dart table constraints into schema 2022-12-16 15:34:07 +01:00
lib Fix `validateDatabaseSchema` in schema tests 2023-03-23 17:56:50 +01:00
test Ignore lints in generated schema code 2023-03-03 20:57:32 +01:00
README.md Write Dart refences into schema files 2022-04-04 22:32:07 +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 Fix `validateDatabaseSchema` in schema tests 2023-03-23 17:56:50 +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

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