Migrations
The migration mental model, the command flow, and the difference between rollout and runtime.
Migrations
comon_orm supports two different schema workflows:
- local setup or bootstrap for disposable databases
- reviewed migrations for shared, long-lived, or production databases
If the database matters, use migrations.
Choose the right path
| Situation | Recommended path |
|---|---|
| Shared PostgreSQL database | Reviewed CLI migrations |
| Shared SQLite database | Reviewed CLI migrations |
| Flutter local cache you can rebuild | Reset or bootstrap instead of versioned migrations |
| Flutter local SQLite with important offline data | Explicit app-side SqliteFlutterMigrator upgrades with Dart-coded schema builder |
| Browser app talking to a backend | Backend owns migrations |
Short version
- runtime adapters should open from generated metadata
migrate devis the normal local command for creating and applying the next migrationmigrate deployapplies reviewed local migrations to shared environmentsmigrate statusis the first command to run when local files and the database may have divergeddb pushupdates a database without creating migration historyrollbackexists, but production usually wants a forward fix rather than a blind revert
Decision rules
- If the database is shared or long-lived, use the CLI workflow.
- If the database is device-local and disposable, prefer reset over maintaining migration code.
- If the database is device-local and contains important user data, upgrade it explicitly before runtime startup.
- Do not mix migration planning into normal app runtime openers.
CLI commands
See the full command set, flags, artifacts, and the meaning of each step.
Shared databases
The reviewed CLI flow for PostgreSQL and shared SQLite databases.
Flutter local SQLite
The decision model for device-local SQLite files and app-side upgrade code.
Rollback and recovery
See rollback, forward-fix guidance, checksum recovery, and artifact recovery.
Troubleshooting
Status mismatch, missing tables, warnings, and migration drift.