packages/cli/README.md
Command line tool for MikroORM. Provides commands for managing database schema, migrations, seeding, and entity generation.
npm install @mikro-orm/cli
MikroORM CLI requires a configuration file or a mikro-orm section in your package.json. The simplest setup:
npx mikro-orm
mikro-orm schema:create # Create database schema
mikro-orm schema:update # Update schema to match entities
mikro-orm schema:drop # Drop database schema
mikro-orm migration:create # Generate migration from schema diff
mikro-orm migration:up # Run pending migrations
mikro-orm migration:down # Revert last migration
mikro-orm migration:list # List executed migrations
mikro-orm seeder:run # Run database seeders
mikro-orm seeder:create # Create a new seeder class
mikro-orm generate-entities # Generate entities from database
mikro-orm cache:generate # Generate metadata cache
mikro-orm cache:clear # Clear metadata cache
The CLI looks for configuration in the following order:
--config flagmikro-orm.config.ts (or .js) in the project rootmikro-orm key in package.json// mikro-orm.config.ts
import { defineConfig } from '@mikro-orm/postgresql';
export default defineConfig({
entities: [Author, Book],
dbName: 'my-db',
});
See the official MikroORM documentation.
Copyright © 2018-present Martin Adámek. Licensed under the MIT License.