CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-mikro-orm--cli

Command-line interface tool for MikroORM TypeScript ORM providing database management, migrations, schema operations, and entity generation

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

database.mddocs/

Database Commands

MikroORM CLI database management commands for core database operations including creation and SQL import functionality.

Capabilities

Create Database

Creates the database if it doesn't exist. Useful for initial setup and CI/CD pipelines.

/**
 * Create database command
 */
command: "database:create"

// No additional options beyond global options

Usage Examples:

# Create database with default configuration
mikro-orm database:create

# Create database with specific config file
mikro-orm database:create --config ./orm.config.js

# Create database for specific context
mikro-orm database:create --context production

Import SQL File

Imports SQL file contents directly into the database. Supports multiple SQL statements and database-specific SQL syntax.

/**
 * Import SQL file command
 */
command: "database:import <file>"

interface ImportOptions extends BaseArgs {
  file: string;  // Path to SQL file to import (required positional argument)
}

Usage Examples:

# Import SQL file
mikro-orm database:import ./schema.sql

# Import with specific configuration
mikro-orm database:import ./data.sql --config ./orm.config.js

# Import for specific context
mikro-orm database:import ./init.sql --context development

Command Arguments

database:create

No additional arguments required beyond global options.

database:import

  • <file>: Required positional argument specifying the path to the SQL file to import

Global Options

All database commands support:

  • --config: Path to ORM configuration file(s)
  • --contextName / --context: Configuration context name

Error Handling

database:create Errors

  • Database already exists: Command will succeed if database already exists
  • Insufficient permissions: Database user must have CREATE DATABASE privileges
  • Connection errors: Network or authentication issues will prevent database creation
  • Driver limitations: Only available for SQL-based drivers (not MongoDB)

database:import Errors

  • File not found: SQL file path must exist and be readable
  • SQL syntax errors: Invalid SQL will cause import to fail
  • Permission errors: Database user must have appropriate INSERT/CREATE privileges
  • Large file handling: Very large SQL files may require connection timeout adjustments
  • Multiple statement support: Driver must support multiple SQL statements

Supported Database Systems

These commands work with:

  • PostgreSQL: Full support for database creation and SQL import
  • MySQL/MariaDB: Full support for database creation and SQL import
  • SQLite: Database creation creates file, SQL import supported
  • MongoDB: Not applicable (NoSQL database)

Related Configuration

Database commands work with these MikroORM configuration options:

interface DatabaseConfiguration {
  driver: string;              // Database driver type
  clientUrl?: string;          // Connection string
  host?: string;              // Database host
  port?: number;              // Database port
  user?: string;              // Database user
  password?: string;          // Database password
  dbName: string;             // Database name
  multipleStatements?: boolean; // Enable multiple SQL statements (for import)
}

docs

cache.md

database.md

debug.md

entities.md

helper-api.md

index.md

migrations.md

schema.md

seeders.md

tile.json