Repository navigation
Database Migrations
Published automatically on 2026-10-28 16:41 UTC. Edit the repository source; direct Wiki edits will be overwritten.
Run all commands from app/.
-
Before changing the schema, ensure the current version has a snapshot in
drift_schemas/6mwt_database/. If missing, run:dart run drift_dev make-migrations
-
Change the tables in
lib/core/data/database.dartand incrementschemaVersion. Regenerate the database code and migration helpers:dart run build_runner build dart run drift_dev make-migrations
-
Implement the upgrade in
AppDatabase.migration. Add afromXToYcallback tostepByStep, using the suppliedschemafor that version. Generation only creates snapshots and helpers; it does not implement the migration. For example, version 1 → 2 usesTableMigrationto add requiredgenderandweightcolumns, filling existing profiles withotherand0.0. -
Test and commit. Extend
test/drift/6mwt_database/migration_test.dartwith existing rows to check data preservation and any replacement values.flutter test test/drift/6mwt_database/migration_test.dart flutter test
Commit the schema changes, migration, snapshots, generated Dart files and tests together. Keep old snapshots unchanged and do not edit generated files manually.
Drift upgrades existing databases automatically when opened. Fresh installations create the latest schema directly.