CLI commands
The schema and migration commands, what each one does, and which artifacts they create.
CLI commands
The unified entry point is the comon_orm CLI.
Schema commands
check
Validates schema.prisma.
dart run comon_orm checkUse it when:
- editing models and relations
- changing enums or native types
- before
generate
validate is kept as an alias.
The docs use check consistently so the command vocabulary stays uniform.
format
Formats the schema file in place.
dart run comon_orm formatgenerate
Generates the Dart client from the schema.
dart run comon_orm generateThis writes the Dart client to the output path from the generator block.
If --schema is omitted, the CLI looks for prisma/schema.prisma first and then schema.prisma.
Migration commands
migrate dev
Creates and applies a new local migration, then updates the generated client.
dart run comon_orm migrate dev --name 20260318_add_post_statusUse it for local development when you want the schema, migration artifact, database, and generated client to move together.
Typical artifact output lives in prisma/migrations and includes:
migration.sqlwarnings.txtbefore.prismaafter.prismametadata.txt
migrate dev also checks for drift against the latest applied local snapshot before creating the next migration.
migrate deploy
Applies already-created local migrations to the target database.
dart run comon_orm migrate deployUse it in CI, staging, and production where migrations should already be reviewed and committed.
migrate reset
Drops the current schema contents, recreates them from the current schema, and regenerates the client.
dart run comon_orm migrate resetUse it only for disposable local databases.
migrate resolve
Repairs migration history when a migration was applied manually or needs to be marked rolled back.
dart run comon_orm migrate resolve --applied 20260318_add_post_statusor:
dart run comon_orm migrate resolve --rolled-back 20260318_add_post_statusmigrate status
Checks whether local migration artifacts and the database history still agree.
dart run comon_orm migrate statusUse this first whenever you suspect drift.
Typical status findings include:
checksum-mismatchapplied-migration-missing-locallylocal-migration-not-appliedmissing-db-snapshotinvalid-local-artifacts
db push
Pushes the current schema directly to the database without creating migration history.
dart run comon_orm db pushUse it for prototypes, temporary databases, and fast local iteration when you do not want to keep migration artifacts.
migrate diff
Compares two schema sources and prints or writes the resulting SQL diff.
dart run comon_orm migrate diff \
--from-migrations prisma/migrations \
--to-schema prisma/schema.prisma \
--scriptSupported source pairs include:
--from-empty--from-schema--from-database--from-migrations--to-schema--to-database--to-migrations--to-empty
Use --output to write the SQL to disk and --exit-code for CI-style checks.
Recovery command
migrate rollback remains available for recovery scenarios when you need to revert to a recorded schema snapshot.
The modern flow is built around migrate dev, migrate deploy, migrate reset, migrate resolve, migrate status, and db push.
Typical flows
Local development
dart run comon_orm check
dart run comon_orm migrate dev --name 20260318_add_post_statusReviewed rollout for shared databases
dart run comon_orm check
dart run comon_orm generate
dart run comon_orm migrate status
dart run comon_orm migrate deploySchema push without migration history
dart run comon_orm check
dart run comon_orm db pushDiagnose a diff between two sources
dart run comon_orm migrate diff \
--from-database \
--to-schema prisma/schema.prisma \
--scriptWarnings are blocking by default
If the planner detects destructive drops, lossy type transitions, enum shrinkage, or rebuild-heavy transitions, migration commands stop unless you pass --allow-warnings after review.
Continue with
- Shared databases for the reviewed rollout path
- Flutter local SQLite for device-local app upgrades
- Rollback and recovery for failure handling and forward-fix guidance