prismo-cli
v0.1.5
Published
A Prisma-based schema generator CLI (generate/destroy models, fields, migrations)
Downloads
646
Maintainers
Readme
✨ Features
✔ Generate & destroy models
✔ Add & remove fields with relation auto-handling
✔ Supported relations:
➡ 1to1, 1toM, Mto1, MtoM
✔ Cascade delete support (--cascade)
✔ Migration automation (--migrate)
✔ DB drop/reset with safety confirmation 🔐
✔ Intelligent CLI suggestions for typos
✔ Fully styled --help menu 🎨
✔ Zero manual schema editing! 😎
📦 Installation
npm install -g prismo-cliVerify installation:
prismo --help$ prismo --help
┌────────────────────────────────────────────────────────────┐
│ Prismo CLI Help
└────────────────────────────────────────────────────────────┘
Usage:
prismo <command> [options]
Commands:
Generate
prismo g model <ModelName> <field:type>... Create a new model
prismo g field <ModelName> <field:type>... Add fields to a model
prismo g relation <RelationType> <ModelName> <TargetModel> [--options]
Destroy
prismo d model <ModelName> Remove a model
prismo d field <ModelName> <Field> Remove a field
Database
prismo db:migrate <name> Create & apply migration
prismo db:reset Reset DB & reapply migrations
prismo db:drop Drop database
prismo db:seed Run Prisma seed script
prismo list models List all models in schema
prismo studio Launch Prisma Studio UI
Options:
-h, --help Show help
-v, --version Show version
-m , --migrate Automatically run migration
--cascade Enable cascade delete
Relation Types:
1to1, 1toM, Mto1, MtoM Specify relation type
Examples:
prismo g model User name:string email:string
prismo g field Post title:string
prismo d model Order
prismo db:migrate "add_users_table"
prismo studio🧱 Usage Examples
Generate a model
prismo g model User name:string age:int -mResult
📌 Creating Model
✔ Schema formatted
✔ Model "User" created successfully!
→ Run migration: prismo db:migrate "add_User"model User {
id Int @id @default(autoincrement())
name String
age Int
}Add a field
prismo g field User bio:string --migrate
Result
✔ Schema formatted
✔ Fields added to User
→ Run: prismo db:migrate "update_User"model User {
id Int @id @default(autoincrement())
name String
age Int
bio String?}Destroy a model safely
prismo d model PostResult
✔ Model "Post" removed successfully!
→ Run migration: prismo db:migrate "remove_post"If dependencies exist:
✖ Cannot destroy model "Post" 🚫
ℹ Other models reference it:
⚠ - Comment
→ Destroy those models first.List all models
prismo list modelsResult
📌 Database Models
✔ 📦 Model: Post
ℹ - id String @id @default(uuid())
ℹ - title String
ℹ - age Int
ℹ - createdAt DateTime @default(now())
→ All models listed.DB Commands
| Command | Description |
| ------------------- | ------------------------- |
| prismo db:migrate | Apply migrations |
| prismo db:drop | Drop DB instantly + delete migrations files as well (Use Carefully) |
| prismo db:reset | Drop + reapply migrations |
RelationShip Examples
- 1to1 Relation
Create the following modelsprismo g model User name:string age:int gender:string --migrate prismo g model Profile title:string --migrate# One User has One Profile prismo g relation 1to1 User Profile --migratemodel User { id String @id @default(uuid()) name String age Int gender String createdAt DateTime @default(now()) updatedAt DateTime @updatedAt profile Profile? } model Profile { id String @id @default(uuid()) title String createdAt DateTime @default(now()) updatedAt DateTime @updatedAt user User @relation(fields: [userId], references: [id]) userId String @unique } - 1toM Relation
Create the following modelsprismo g model User name:string age:int --migrate prismo g model Post title:string content:string --migrate# One User can have Many Posts prismo g relation 1toM User Post --migrate --cascademodel User { id String @id @default(uuid()) name String age Int createdAt DateTime @default(now()) updatedAt DateTime @updatedAt posts Post[] } model Post { id String @id @default(uuid()) title String content String createdAt DateTime @default(now()) updatedAt DateTime @updatedAt user User @relation(fields: [userId], references: [id], onDelete: Cascade) userId String } - Mto1 Relation
Create the following models
prismo g model Category name:string --migrate prismo g model Product name:string --migrate# Many Products belong to One Category prismo g relation Mto1 Product Category --migratemodel Category { id String @id @default(uuid()) name String createdAt DateTime @default(now()) updatedAt DateTime @updatedAt products Product[] } model Product { id String @id @default(uuid()) name String createdAt DateTime @default(now()) updatedAt DateTime @updatedAt category Category @relation(fields: [categoryId], references: [id]) categoryId String } - MtoM Relation
Create the following models
prismo g model Author name:string --migrate prismo g model Book title:string --migrate# Many Authors can write Many Books prismo g relation MtoM Author Book --migratemodel Author { id String @id @default(uuid()) name String createdAt DateTime @default(now()) updatedAt DateTime @updatedAt books Book[] @relation("AuthorBooks") } model Book { id String @id @default(uuid()) title String createdAt DateTime @default(now()) updatedAt DateTime @updatedAt authors Author[] @relation("AuthorBooks") }
🧑💻 Contributing
- Fork the project
- Create a feature branch
- Submit a PR Before submitting, run:
# to link your local changes for testing.
npm link# test commads locally
prismo list models🧩 Issue Templates
Bug report template:
**Command executed:**
prismo [...]
**Expected behavior:**
**Actual behavior:**
**Prisma schema preview:**👨💻 Author
Made with ❤️ by Manoj Sharma Follow the project ⭐ and contribute!
📜 License
MIT License — Free for commercial & personal usage.
