Skip to main content

CLI Overview

The Ormed CLI manages migrations, seeds, and schema tooling.

Prerequisites

What You’ll Learn

  • How to run CLI commands in local and global modes
  • How config discovery and connection targeting work
  • How production guard behavior affects migration/seed operations

Step Outcome

By the end of this page, you should be able to:

  • Run the CLI reliably in your preferred mode (dart run or global)
  • Target the intended config/connection for each command
  • Understand when production guard prompts appear

By default it works in code-first mode (no ormed.yaml required) using convention paths. Use ormed.yaml when you want explicit connection blocks and config-driven CLI wiring.

Running the CLI

Use this if you have ormed_cli in your dev_dependencies. This ensures version parity with your project.

dart run ormed_cli:ormed --help
dart run ormed_cli:ormed init
dart run ormed_cli:ormed migrate
warning

Adding ormed_cli to your project will pull in all database drivers (SQLite, MySQL, Postgres) as transitive dependencies.

Use dart run for team consistency. Use global install for convenience on personal environments.

Config discovery

If present, the CLI finds the nearest ormed.yaml by walking up from the current directory.

If missing, CLI commands fall back to convention defaults:

  • driver: sqlite
  • database: database/<package>.sqlite
  • migrations registry: lib/src/database/migrations.dart
  • seed registry: lib/src/database/seeders.dart

The seed registry path is convention-only unless you scaffold it (ormed init --with-seeders / ormed init --only=seeders) or create your first seeder (ormed make:seeder).

Override the config path explicitly:

dart run ormed_cli:ormed migrate --config path/to/ormed.yaml

Targeting connections

If your ormed.yaml contains multiple connections, target one with:

dart run ormed_cli:ormed migrate --connection analytics
dart run ormed_cli:ormed seed --connection analytics

Production guard

Commands that mutate schema/data prompt for confirmation when the process environment indicates production (ORM_ENV, DART_ENV, FLUTTER_ENV, or ENV equals production).

Use --force (when supported) to skip the prompt.

Quick Verification

dart run ormed_cli:ormed --help
dart run ormed_cli:ormed migrate --pretend

If you use ormed.yaml, also test explicit targeting:

dart run ormed_cli:ormed migrate --config ormed.yaml --connection default --pretend

Read This Next