model User { id Int @id @default(autoincrement()) email String @unique name String? posts Post[]}model Post { id Int @id @default(autoincrement()) title String content String? authorId Int author User @relation(fields: [authorId], references: [id])}
2
Push to Database
prisma db push
Output:
Datasource "db": PostgreSQL database "mydb" at "localhost:5432"Your database is now in sync with your Prisma schema. Done in 45ms
The database schema is updated immediately without creating migration files.
When changes may result in data loss, you’ll see a warning:
⚠️ There might be data loss when applying the changes: • You are about to drop the column `age` on the `User` table.Do you want to ignore the warning(s)?
Some changes cannot be executed without manual intervention:
⚠️ We found changes that cannot be executed: • Added the required column `authorId` to the `Post` table without a default value.You may use the --force-reset flag to drop the database before push.All data will be lost.
model User { id Int @id @default(autoincrement()) email String @unique}
prisma db push
2
Rapid Iteration
Add fields and models as you experiment:
model User { id Int @id @default(autoincrement()) email String @unique name String? createdAt DateTime @default(now()) profile Profile?}model Profile { id Int @id @default(autoincrement()) bio String? userId Int @unique user User @relation(fields: [userId], references: [id])}
prisma db push
3
Continue Testing
Test your changes, iterate quickly:
# Make more changesprisma db push# Testnpm run dev# Adjust schemaprisma db push
4
Switch to Migrations
When your schema stabilizes, switch to migrations:
# Create initial migration from current schemaprisma migrate dev --name init
Now you’re using migration-based workflow for production-ready changes.
# Rapid changes without migrationsprisma db pushprisma db pushprisma db push# When POC is approved, create proper migrationsprisma migrate dev --name implement_poc