Migration Guide
Move from the old generated helper API to ComonOrm, reviewed SQL migrations, and asset-backed Flutter startup.
Migration Guide
This page maps the older comon_orm API shape onto the current one.
Use it when upgrading existing apps, examples, or internal snippets.
High-level changes
- generated client class name is now
ComonOrm - provider openers now live on
ComonOrmitself - runtime, codegen, and migration imports are split more explicitly
- Flutter local SQLite no longer uses a separate Dart-only migration DSL
- reviewed
.sqlmigrations are now the shared migration format across CLI and runtime
Rename map
| Old API | New API |
|---|---|
GeneratedComonOrmClient | ComonOrm |
GeneratedComonOrmClient.openInMemory() | ComonOrm.inMemory() |
GeneratedComonOrmClientSqlite.open(...) | ComonOrm.sqlite(...) |
GeneratedComonOrmClientFlutterSqlite.open(...) | ComonOrm.sqlite(...) for generated openers, or SqliteDatabaseAdapter.openFromGeneratedSchema(...) when you need to migrate before building the client |
GeneratedComonOrmClientPostgresql.open(...) | ComonOrm.postgres(...) |
GeneratedComonOrmMetadata | internal _ComonOrmRuntimeMetadata |
GeneratedComonOrmClient.runtimeSchema | ComonOrm.runtimeSchema |
Basic upgrade
Old generated client usage:
import 'generated/comon_orm_client.dart';
final db = await GeneratedComonOrmClientSqlite.open();New generated client usage:
import 'generated/comon_orm_client.dart';
final db = await ComonOrm.sqlite();Old in-memory test setup:
final db = GeneratedComonOrmClient.openInMemory();New in-memory test setup:
final db = ComonOrm.inMemory();Old PostgreSQL startup:
final db = await GeneratedComonOrmClientPostgresql.open();New PostgreSQL startup:
final db = await ComonOrm.postgres();Import changes
The public surface is narrower now.
Use:
package:comon_orm/comon_orm.dartfor runtime APIspackage:comon_orm/codegen.dartfor schema parsing, validation, and generator toolingpackage:comon_orm/migrations.dartfor migration abstractions and artifact helperspackage:comon_orm_sqlite/comon_orm_sqlite.dartfor sqlite runtimepackage:comon_orm_sqlite/migrations.dartfor sqlite CLI and schema toolingpackage:comon_orm_postgresql/comon_orm_postgresql.dartfor postgresql runtimepackage:comon_orm_postgresql/migrations.dartfor postgresql migration and schema tooling
If older code imported one broad barrel and used both runtime and tooling symbols, split those imports now.
Flutter local SQLite migration change
The biggest behavioral change is Flutter startup.
Older Flutter code often used app-side migration helpers like:
SqliteFlutterMigratorSqliteFlutterMigrationupgradeSqliteFlutterDatabase(...)
That path is gone.
Use reviewed .sql migrations instead:
import 'package:comon_orm_sqlite_flutter/comon_orm_sqlite_flutter.dart';
import 'generated/comon_orm_client.dart';
final adapter = await SqliteDatabaseAdapter.openFromGeneratedSchema(
schema: ComonOrm.runtimeSchema,
databasePath: 'app.db',
);
await ComonOrm.migrate(
adapter: adapter,
migrations: migrationReaderFromAssets('assets/migrations'),
);
final db = ComonOrm(adapter: adapter);Operationally this means:
- create migrations through the normal CLI flow
- bundle the reviewed
migrations/artifact tree into Flutter assets - apply them at startup with
ComonOrm.migrate(...) - build the typed runtime client only after migration succeeds
CLI command notes
dart run comon_orm checkis the preferred schema validation commanddart run comon_orm validatestill exists as a compatibility aliasmigrate devcreates and applies the next reviewed.sqlmigration locallymigrate deployapplies already-reviewed local migrations to shared environments
Migration checklist
When updating an older app or example:
- Regenerate the client so the generated output becomes
ComonOrm. - Replace old provider helper class calls with
ComonOrm.inMemory(),ComonOrm.sqlite(...), orComonOrm.postgres(...). - Split imports if runtime code was relying on tooling symbols from
package:comon_orm/comon_orm.dart. - Remove Flutter-only migration DSL usage and switch to asset-backed reviewed SQL migrations.
- Re-run the focused runtime and migration tests for the touched package.
When not to change startup shape
If you need to migrate before creating the typed client, open the adapter first and then construct ComonOrm(adapter: adapter) yourself.
That is expected for:
- Flutter local SQLite startup with bundled assets
- custom adapter factories
- advanced bootstrap flows where you need direct access to the adapter before delegates are used