Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.dbdock.xyz/llms.txt

Use this file to discover all available pages before exploring further.

npx dbdock analyze <database-url>
analyze reads the structure of a database — MongoDB or PostgreSQL — and reports what’s inside. Use it before running a cross-database migration to understand what you’re migrating.

Examples

Analyze MongoDB

npx dbdock analyze "mongodb://localhost:27017/myapp"

Analyze PostgreSQL

npx dbdock analyze "postgresql://user:pass@localhost:5432/myapp"

What it reports

For MongoDB

  • Collection names and document counts
  • Field names per collection
  • Inferred types per field (with frequency if heterogeneous)
  • Nesting depth
  • Potential reference fields (_id patterns that look like foreign keys)
  • Index coverage

For PostgreSQL

  • Table names and row counts
  • Column types and nullability
  • Primary and foreign keys
  • Indexes
  • Sequence/identity columns

Sample output (MongoDB)

Database: myapp (mongodb://localhost:27017)
Collections: 4

┌──────────────┬──────────┬────────┬─────────┐
│ Collection   │ Documents│ Fields │ Indexes │
├──────────────┼──────────┼────────┼─────────┤
│ users        │   12,450 │     8  │    3    │
│ orders       │   48,910 │    12  │    5    │
│ products     │      820 │    14  │    2    │
│ reviews      │    3,180 │     6  │    1    │
└──────────────┴──────────┴────────┴─────────┘

users:
  _id            ObjectId     (unique)
  email          String       (unique, 12,450 values)
  name           String
  age            Number       (99.2% Int, 0.8% Double)  ⚠️ mixed types
  created_at     Date
  metadata       Object       (nested, depth 2)
  deleted_at     Date|null
  tags           Array<String>

⚠️ Inconsistencies found:
  • users.age has mixed numeric types (Int and Double)
  • orders.total has 12 documents missing the field
  • products.price has 3 documents with type String instead of Number

What to do with the output

Spot inconsistencies early

Mixed types and missing fields cause migration errors. Fix them in the source first when you can.

Plan the schema

Decide which nested objects to flatten vs keep as jsonb.

Pick batch size

Huge collections need smaller batches (see --batch-size).

Export to config

Save the proposed mapping with dbdock migrate --export-config.

Read-only

analyze only reads — it doesn’t modify the source database. Safe to run against production.

See also

dbdock migrate

Run the actual migration.

Schema mapping

How DBdock maps types.