Command-line interface tool for MikroORM TypeScript ORM providing database management, migrations, schema operations, and entity generation
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
MikroORM CLI schema management commands for creating, updating, dropping, and recreating database schemas based on entity definitions. These commands provide direct schema manipulation capabilities for development and deployment workflows.
Creates database schema based on current entity metadata. Generates tables, indexes, and constraints from entity definitions.
/**
* Create database schema command
*/
command: "schema:create"
interface SchemaCreateOptions extends BaseArgs {
run?: boolean; // Execute queries (--run / -r)
dump?: boolean; // Dump queries to console (--dump / -d)
fkChecks?: boolean; // Include foreign key checks (--fk-checks)
schema?: string; // Set current schema for wildcard entities (--schema)
seed?: string; // Seed database after creation (--seed)
}Usage Examples:
# Display schema creation queries without executing
mikro-orm schema:create --dump
# Create schema and execute queries
mikro-orm schema:create --run
# Create schema and seed with data
mikro-orm schema:create --run --seed DatabaseSeeder
# Create for specific schema with FK checks
mikro-orm schema:create --run --schema public --fk-checksUpdates existing database schema to match current entity definitions. Handles adding/modifying columns, indexes, and constraints.
/**
* Update database schema command
*/
command: "schema:update"
interface SchemaUpdateOptions extends BaseArgs {
run?: boolean; // Execute queries (--run / -r)
dump?: boolean; // Dump queries to console (--dump / -d)
fkChecks?: boolean; // Include foreign key checks (--fk-checks)
schema?: string; // Set current schema for wildcard entities (--schema)
safe?: boolean; // Disable table and column dropping (--safe)
dropTables?: boolean; // Control table dropping (--drop-tables, default: true)
}Usage Examples:
# Show update queries without executing
mikro-orm schema:update --dump
# Update schema safely (no drops)
mikro-orm schema:update --run --safe
# Update with table dropping disabled
mikro-orm schema:update --run --drop-tables=false
# Update specific schema
mikro-orm schema:update --run --schema myschemaDrops database schema including all tables, indexes, and constraints. Provides options for complete database cleanup.
/**
* Drop database schema command
*/
command: "schema:drop"
interface SchemaDropOptions extends BaseArgs {
run?: boolean; // Execute queries (--run / -r)
dump?: boolean; // Dump queries to console (--dump / -d)
fkChecks?: boolean; // Include foreign key checks (--fk-checks)
schema?: string; // Set current schema for wildcard entities (--schema)
dropMigrationsTable?: boolean; // Drop migrations table (--drop-migrations-table)
dropDb?: boolean; // Drop entire database (--drop-db)
}Usage Examples:
# Show drop queries without executing
mikro-orm schema:drop --dump
# Drop schema but keep migrations table
mikro-orm schema:drop --run
# Drop schema including migrations table
mikro-orm schema:drop --run --drop-migrations-table
# Drop entire database
mikro-orm schema:drop --run --drop-dbDrops existing schema and recreates it from current entity definitions. Combines drop and create operations for clean schema reset.
/**
* Drop and recreate database schema command
*/
command: "schema:fresh"
interface SchemaFreshOptions extends BaseArgs {
run?: boolean; // Execute queries (--run / -r)
schema?: string; // Set current schema for wildcard entities (--schema)
seed?: string; // Seed database after recreation (--seed)
dropDb?: boolean; // Drop entire database before recreating (--drop-db)
}Usage Examples:
# Fresh schema recreation (must use --run)
mikro-orm schema:fresh --run
# Fresh schema with seeding
mikro-orm schema:fresh --run --seed TestDataSeeder
# Fresh with database drop and recreation
mikro-orm schema:fresh --run --drop-db
# Fresh for specific schema
mikro-orm schema:fresh --run --schema test_schemaSchema commands require either --run or --dump option:
--run: Execute the schema operations--dump: Display SQL queries without executingWithout one of these options, the command will show help instead of executing.
--dump first to review queries--safe for update operations to prevent data lossAll schema commands support:
--config: Path to ORM configuration file(s)--contextName / --context: Configuration context name--run / -r: Execute the SQL queries--dump / -d: Display queries in console without executing--schema: Set current schema name for wildcard schema entities--fk-checks: Include foreign key constraint checks (create/update/drop only)--seed: Run specified seeder class after schema creation--safe: Disable destructive operations (table/column dropping)--drop-tables: Control whether tables can be dropped (default: true)--drop-migrations-table: Include migrations table in drop operation--drop-db: Drop entire database instead of just schema--drop-db: Drop and recreate entire database--run or --dumpSchema commands work with:
Schema operations use these configuration options:
interface SchemaConfiguration {
schemaGenerator?: {
disableForeignKeys?: boolean; // Disable FK checks during operations
createForeignKeyConstraints?: boolean; // Create FK constraints
};
schema?: string; // Default schema name
entities: string[]; // Entity definitions for schema generation
}