_/_/_/ _/_/_/ _/_/_/ _/_/_/ _/ _/ _/_/ _/ _/ _/ _/ _/ _/ _/_/ _/_/ _/ _/ _/_/_/ _/_/_/ _/ _/_/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/_/_/ _/_/_/ _/ _/ _/_/
A Prisma-powered schema generator CLI
Generate models, fields, migrations just like Rails β but for Prisma π―
β 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! π
npm install -g prismo-cliprismo --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 studioprismo g model User name:string age:int -mπ 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
}prismo g field User bio:string --migrate
β 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?}prismo d model Post
β Model "Post" removed successfully!
β Run migration: prismo db:migrate "remove_post"
β Cannot destroy model "Post" π«
βΉ Other models reference it:
β - Comment
β Destroy those models first.
prismo list models
π Database Models
β π¦ Model: Post
βΉ - id String @id @default(uuid())
βΉ - title String
βΉ - age Int
βΉ - createdAt DateTime @default(now())
β All models listed.
| 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 |
- 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") }
- 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**Command executed:**
prismo [...]
**Expected behavior:**
**Actual behavior:**
**Prisma schema preview:**
Made with β€οΈ by Manoj Sharma Follow the project β and contribute!
MIT License β Free for commercial & personal usage.