cocomon

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 check

Use 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 format

generate

Generates the Dart client from the schema.

dart run comon_orm generate

This 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_status

Use 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.sql
  • warnings.txt
  • before.prisma
  • after.prisma
  • metadata.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 deploy

Use 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 reset

Use 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_status

or:

dart run comon_orm migrate resolve --rolled-back 20260318_add_post_status

migrate status

Checks whether local migration artifacts and the database history still agree.

dart run comon_orm migrate status

Use this first whenever you suspect drift.

Typical status findings include:

  • checksum-mismatch
  • applied-migration-missing-locally
  • local-migration-not-applied
  • missing-db-snapshot
  • invalid-local-artifacts

db push

Pushes the current schema directly to the database without creating migration history.

dart run comon_orm db push

Use 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 \
  --script

Supported 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_status

Reviewed 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 deploy

Schema push without migration history

dart run comon_orm check
dart run comon_orm db push

Diagnose a diff between two sources

dart run comon_orm migrate diff \
  --from-database \
  --to-schema prisma/schema.prisma \
  --script

Warnings 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

On this page