TypeORM CLI
$ typeorm Official Med RiskTypeORM CLI (typeorm) inspects TypeScript/JavaScript entities against a database DataSource to list migrations (migration:show), generate diffed migration classes (migration:generate), preview pending schema SQL (schema:log), and run migrations (migration:run).
npm install -D typeorm typeorm compiles and diffs local TypeScript @Entity classes via -d data-source directly inside the repo.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
Predictable subcommands (migration:show, schema:log), though TypeScript projects often need typeorm-ts-node-commonjs / typeorm-ts-node-esm wrappers and output lacks --json.
- Non-interactive
migration:showandschema:log - Requires
-dDataSource path and lacks--json
schema:log and migration:generate allow inspection before execution, but migration:run lacks --dry-run and schema:sync/schema:drop are dangerous if run blindly.
schema:logpreviews DDL without applying; no--dry-runonmigration:run
Standard npm CLI, though running against .ts DataSource files requires ts-node or pre-compiled JS output.
- Requires Node.js,
ts-node(for TS), and project DB driver packages
Automatically diffs TypeScript @Entity metadata against live DB schemas to scaffold up/down migrations.
- Automates entity-to-SQL migration generation
Official typeorm/typeorm project under MIT license with large TypeScript ecosystem usage.
- Official
typeorm/typeormrepository under MIT
Documented CLI commands at typeorm.io/using-cli, though TS/ESM loader setup often trips users up.
- CLI reference at typeorm.io/using-cli
Security, Auth & Guardrails
Reads connection settings from the -d <data-source> file (commonly backed by DATABASE_URL or DB_* env vars).
MIT open-source npm package; free to use.
# TypeORM CLI Agent Rules - Always pass `-d <path-to-data-source>` and inspect `schema:log` or generated migration SQL before running `migration:run`. - NEVER run `schema:drop` or `schema:sync` against shared/production databases.
Agent-Ready Command Recipes
Safe Read-Only Queries
npx typeorm-ts-node-commonjs migration:show -d src/data-source.ts
Prints [X] for executed migrations and [ ] for pending migrations without mutating the DB.
npx typeorm-ts-node-commonjs schema:log -d src/data-source.ts
Outputs the exact SQL statements schema:sync would run so agents can inspect entity drift safely.
Controlled Writes & Previews
npx typeorm-ts-node-commonjs migration:generate src/migrations/UpdateSchema -d src/data-source.ts
Writes a reviewable up/down TypeScript migration file locally without applying it to the database.
Strengths for Agents
- +
schema:logprints exact pending DDL SQL without touching the database. - +
migration:generatecreates inspectable TypeScriptup/downfiles from entity diffs. - +
migration:showclearly marks executed vs pending migrations.
Caveats & Pitfalls
- ! No
--jsonoutput and no--dry-runflag onmigration:run. - ! TypeScript projects must invoke
typeorm-ts-node-commonjsortypeorm-ts-node-esm(or compile first).