Skip to content

πŸš€ Prisma-powered schema generator CLI β€” generate models, fields, relations & migrations. Rails-like workflow for Prisma ORM.

Notifications You must be signed in to change notification settings

ErManoj-Sharma/prismo-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

23 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

 _/_/_/    _/_/_/    _/_/_/    _/_/_/  _/      _/    _/_/    
_/    _/  _/    _/    _/    _/        _/_/  _/_/  _/    _/   
_/_/_/    _/_/_/      _/      _/_/    _/  _/  _/  _/    _/    
_/        _/    _/    _/          _/  _/      _/  _/    _/     
_/        _/    _/  _/_/_/  _/_/_/    _/      _/    _/_/        

Prismo CLI πŸš€

A Prisma-powered schema generator CLI
Generate models, fields, migrations just like Rails β€” but for Prisma 🎯


✨ 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-cli

Verify 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 -m

Result

πŸ“Œ 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 Post

Result

βœ” 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 models

Result

πŸ“Œ 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

  1. 1to1 Relation
    Create the following models
    prismo 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  --migrate
    model 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
    }
  2. 1toM Relation
    Create the following models
    prismo 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 --cascade
    model 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
     }
  3. 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 --migrate
    model 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
    }
  4. 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 --migrate
    model 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

  1. Fork the project
  2. Create a feature branch
  3. 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.

πŸ“’ If this tool saves you time, please star ⭐ the repo β€” it really helps!

About

πŸš€ Prisma-powered schema generator CLI β€” generate models, fields, relations & migrations. Rails-like workflow for Prisma ORM.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published