cocomon

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

SituationRecommended path
Shared PostgreSQL databaseReviewed CLI migrations
Shared SQLite databaseReviewed CLI migrations
Flutter local cache you can rebuildReset or bootstrap instead of versioned migrations
Flutter local SQLite with important offline dataExplicit app-side SqliteFlutterMigrator upgrades with Dart-coded schema builder
Browser app talking to a backendBackend owns migrations

Short version

  • runtime adapters should open from generated metadata
  • migrate dev is the normal local command for creating and applying the next migration
  • migrate deploy applies reviewed local migrations to shared environments
  • migrate status is the first command to run when local files and the database may have diverged
  • db push updates a database without creating migration history
  • rollback exists, but production usually wants a forward fix rather than a blind revert

Decision rules

  1. If the database is shared or long-lived, use the CLI workflow.
  2. If the database is device-local and disposable, prefer reset over maintaining migration code.
  3. If the database is device-local and contains important user data, upgrade it explicitly before runtime startup.
  4. Do not mix migration planning into normal app runtime openers.

On this page