M MigratoryAI

Documentation

Everything you need to run MigratoryAI with npm or npx.

MigratoryAI is a CLI package for analyzing NoSQL data, inferring SQL-ready structure, previewing migration output, migrating in batches, validating results, and parsing log files into structured documents.

Install

Choose the way you want to run it.

npx

npx migratoryai --help

Best for trying the CLI quickly with no global install.

Global install

npm install -g migratoryai

Best for regular use across projects and migration workflows.

Quick start

Basic workflow

  1. Create your `.env` or `migrate.config.json`.
  2. Check your target SQL database connection.
  3. Analyze the source collection.
  4. Preview with dry-run or run a real migration.
  5. Validate counts after migration.
migratoryai target-check
migratoryai analyze --entity users --limit 5
migratoryai migrate --entity users --limit 500 --batch-size 100 --validate

Commands

Core CLI commands

`migratoryai analyze`

Fetch sample source data, infer the relational shape, and print SQL suggestions.

`migratoryai migrate`

Move source data into SQL with batching, retries, and optional validation.

`migratoryai validate`

Compare expected row counts from source data against the SQL target.

`migratoryai target-check`

Verify target database connectivity before running migrations. `pg-check` remains as an alias.

`migratoryai ingest`

Parse a log file into structured documents and route output to JSON, PostgreSQL, or MongoDB. Use --llm-fallback for AI-powered parsing of ambiguous lines.

New in v1.3.0

Log ingestion

Parse log files into structured documents.

Basic usage

migratoryai ingest logs.txt

Parses the log file and writes structured JSON to a file named logs-parsed.json in the current directory.

With AI fallback

migratoryai ingest logs.txt --llm-fallback

Retries unparsed lines with AI Haiku. Requires ANTHROPIC_API_KEY to be set.

migratoryai ingest logs.txt --output postgres
migratoryai ingest logs.txt --output mongo --collection app_logs
migratoryai ingest logs.txt --output ./out/parsed.json

--output <target>

Where to send parsed documents. Accepts json (default), postgres, mongo, or a direct file path. When json is used without a path, output defaults to <input-name>-parsed.json.

--collection <name>

Collection or table name for the parsed output. Defaults to logs.

--llm-fallback

Retry lines the regex parser cannot handle using AI Haiku. Requires ANTHROPIC_API_KEY. Lines that still cannot be parsed are preserved in the unparsed list.

Output shape

{
  "level": "ERROR",
  "event": "payment_failed",
  "user_id": "123",
  "timestamp": "2026-05-13T10:34:22.000Z",
  "raw_message": "[ERROR] event=payment_failed user_id=123"
}

Supported log formats

  • Bracket and prose: [INFO] Payment failed for user 999 at 14:02
  • Key-value pairs: [ERROR] event=payment_failed user_id=123 timestamp=10:32
  • ISO timestamp with key-value: [2026-05-13T10:34:22Z] [ERROR] event=payment_failed user_id=456
  • Logfmt: time=2026-05-13T10:34:22Z level=error event=payment_failed user_id=789
  • JSON log lines (Winston, Docker, plain JSON): {"level":"error","message":"Payment failed","userId":"123"}
  • Python standard logging, Spring Boot, Rails logger, and syslog-style

Environment variables

ANTHROPIC_API_KEY

Required when using --llm-fallback. AI Haiku is used to parse log lines the regex engine cannot structure.

CLAUDE_LOG_PARSER_MODEL

Optional model override for the AI fallback parser. Defaults to claude-haiku-4-5-20251001.

Configuration

Use `.env`, `migrate.config.json`, or CLI flags.

{
  "source": {
    "type": "mongodb",
    "uri": "mongodb://127.0.0.1:27017",
    "dbName": "sample_mflix",
    "entityName": "users",
    "collectionName": "users"
  },
  "target": {
    "type": "postgres",
    "host": "127.0.0.1",
    "port": 5432,
    "user": "postgres",
    "password": "postgres",
    "database": "migratoryai"
  },
  "options": {
    "limit": 1000,
    "batchSize": 250,
    "retries": 3,
    "validate": true
  }
}

CLI flags override config-file values, and config values override environment fallbacks.

Safety

Built for reruns, validation, and migration confidence.

  • Dry-run mode previews SQL and planned rows before writing.
  • Fingerprint-based upserts support safe reruns without duplicate rows.
  • Validation compares expected source-derived counts to the SQL target.
  • Batch retries and transaction handling improve reliability during longer runs.