@mostajs/orm-cliPart of the
@mostajs/ormecosystem — the multi-dialect ORM with one API across 13 databases. This post zooms in on the migration CLI.
One command turns an existing Prisma app into a @mostajs/orm
app that runs on any of 13 databases — and you don’t
edit a single line of application code:
cd my-existing-prisma-app
npx @mostajs/orm-cli bootstrap
npm run dev
# db.User.findMany(...) now runs on SQLite / Postgres / MySQL / Mongo / Oracle / … — same code.new PrismaClient(...), backs the originals up, and is
reversible.Prisma is great until the day you need a different database — Mongo for one service, Postgres for another, SQLite for local dev or an embedded build, Oracle because the client mandates it. Prisma’s schema, client and migrations are tied to one provider; switching means rewriting data access across the whole codebase.
@mostajs/orm-cli removes that wall. Its headline
command, mostajs bootstrap, performs the migration
for you — codemod included — so the same
db.User.findMany() calls keep working, now on top of an ORM
that speaks 13 dialects.
mostajs bootstrap actually doesFour steps, each gated on the previous succeeding (v0.4.1+):
new PrismaClient(...), detects each export name
(prisma, db, client, default…),
and rewrites each site to createPrismaLikeDb() from
@mostajs/orm-bridge. Originals saved as
*.prisma.bak.@mostajs/orm +
@mostajs/orm-bridge +
@mostajs/orm-adapter.prisma/schema.prisma →
.mostajs/generated/entities.json (a 13-database-ready
schema)..mostajs/config.env
(SQLite defaults) and creates the tables.The “zero code change” isn’t a slogan:
@mostajs/orm-bridge exposes a Prisma-compatible
client, so your db.user.findMany(...) calls hit it
unchanged. The codemod just swaps what db is.
The codemod (mostajs install-bridge) is dry-run
by default — it reports, it doesn’t write:
$ mostajs install-bridge
Found 3 PrismaClient instantiation site(s):
→ src/lib/db.ts (const db)
→ src/server/prisma.ts (const prisma)
→ scripts/seed.ts (const prisma)
Dry-run — no files written. Re-run with --apply to execute.
It only acts on files that import @prisma/client
and call new PrismaClient( — and it
skips files already migrated, so re-runs are
idempotent. Every rewritten file leaves a .prisma.bak next
to it, and one command rolls the whole thing back:
npx @mostajs/orm-cli install-bridge --restore --applyNo black box: you can see what changed, and you can undo it.
Bootstrap configures SQLite so it works immediately. To target any of
the other twelve, edit .mostajs/config.env:
DB_DIALECT=postgres
SGBD_URI=postgres://user:pass@host:5432/mydbThe thirteen: SQLite · PostgreSQL · MySQL · MariaDB · MongoDB · Oracle · SQL Server · CockroachDB · DB2 · SAP HANA · HSQLDB · Spanner · Sybase. Same converted schema, same application code — you change two env lines and re-init.
The converter auto-detects more than Prisma schemas — it also reads
OpenAPI (openapi.yaml/json) and
JSON Schema (schemas/*.json), routing
through @mostajs/orm-adapter. So “I have an API spec but no
ORM” is also a starting point, not just “I have Prisma”.
This isn’t a toy demo. FitZoneGym — a production-grade Next.js 15 + Prisma app, 40 models, 67 files importing Prisma — was migrated with one bootstrap:
cd FitZoneGym
npx @mostajs/orm-cli bootstrap # 15 PrismaClient sites rewritten, schema converted, DDL applied
npm run dev # login alice@example.com → 302 + session, on SQLite instead of MongoDBFiles edited by hand: 0 — the codemod owned them all. Login, dashboard and API routes ran on SQLite instead of MongoDB, unchanged.
Beyond bootstrap, the CLI carries the everyday utilities
you actually need around a database: mostajs health (Node /
schema / entities.json checks), mostajs detect
(what’s in the project), mostajs hash / verify
(bcrypt for seed data), mostajs diagnose (login
walkthrough), and a full interactive menu
(mostajs with no args) for converting, configuring URIs,
init/DDL, seeding, services and logs.
One caveat worth stating: this package is an executable, not a library — install and run it, don’t
importfrom it.
mostajs bootstrap is the on-ramp to @mostajs/orm:
after it, you own a 13-database-ready schema and a Prisma-compatible
runtime via @mostajs/orm-bridge. To move the data
across dialects after the code moves, pair it with @mostajs/orm-copy-data
(the bootstrap uses that engine internally). For ongoing replication,
see @mostajs/replicator.
npx @mostajs/orm-cli bootstrap # zero-install, in your Prisma project
# or: npm install -g @mostajs/orm-cli → mostajs bootstrap@mostajs/orm — 13
databases, one API, zero codegenIf escaping single-database lock-in with one reversible command is useful, a ⭐ on GitHub helps — it’s the signal AI dev tools use to surface the package.
Tags: #nodejs #typescript
#prisma #database #migration
#postgresql #mysql #mongodb
#sqlite #orm #codemod
#mostajs
Auteur : Dr Hamid MADANI drmdh@msn.com