Part of the
@mostajs/ormecosystem — the multi-dialect ORM with one API across 13 databases. This post zooms in on the migration CLI.
TL;DR
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.
- A codemod rewrites every
new PrismaClient(...), backs the originals up, and is reversible. - Every step stops on the first error — no lying success banner.
- Real proof: a 40-model, 67-file Next.js app migrated end-to-end with 0 files touched by hand.
The problem: Prisma marries you to one database
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.
What mostajs bootstrap actually does
Four steps, each gated on the previous succeeding (v0.4.1+):
-
Codemod — scans the repo for
new PrismaClient(...), detects each export name (prisma,db,client, default…), and rewrites each site tocreatePrismaLikeDb()from@mostajs/orm-bridge. Originals saved as*.prisma.bak. -
Install — adds
@mostajs/orm+@mostajs/orm-bridge+@mostajs/orm-adapter. -
Convert —
prisma/schema.prisma→.mostajs/generated/entities.json(a 13-database-ready schema). -
DDL — writes
.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.
Safe by default, and reversible
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 --apply
No black box: you can see what changed, and you can undo it.
Pick your database afterwards
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/mydb
The 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.
Not just Prisma at the input
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".
Proof — FitZoneGym
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 MongoDB
Files edited by hand: 0 — the codemod owned them all. Login, dashboard and API routes ran on SQLite instead of MongoDB, unchanged.
More than migration
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.
Where it fits
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.
Get started
npx @mostajs/orm-cli bootstrap # zero-install, in your Prisma project
# or: npm install -g @mostajs/orm-cli → mostajs bootstrap
- 📦 npm — npmjs.com/package/@mostajs/orm-cli
- 🐙 GitHub — github.com/apolocine/mosta-orm-cli
- 🧩 The ORM it migrates you to —
@mostajs/orm— 13 databases, one API, zero codegen
If 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.
Auteur : Dr Hamid MADANI drmdh@msn.com
Top comments (0)