Prisma schema loaded from prisma/schema.prisma.Datasource "db": PostgreSQL database "production_db" at "localhost:5432"- Introspecting based on datasource defined in prisma/schema.prisma✔ Introspected 3 models and wrote them into prisma/schema.prisma in 127msRun prisma generate to generate Prisma Client.
3
Review Generated Schema
Your Prisma schema now contains models matching your database:
model User { id Int @id @default(autoincrement()) email String @unique(map: "User_email_key") name String? created_at DateTime @default(now()) @db.Timestamptz(6) posts Post[]}model Post { id Int @id @default(autoincrement()) title String content String? published Boolean @default(false) author_id Int author User @relation(fields: [author_id], references: [id], onDelete: Restrict)}
/// User account informationmodel User { id Int @id @default(autoincrement()) email String @unique firstName String @map("first_name") // Custom mapping}
After prisma db pull (enrichment):
/// User account informationmodel User { id Int @id @default(autoincrement()) email String @unique firstName String @map("first_name") // Preserved lastName String @map("last_name") // New field added}
After prisma db pull --force (replacement):
model User { id Int @id @default(autoincrement()) email String @unique(map: "User_email_key") first_name String // Lost custom mapping last_name String}
Error: P4001The introspected database was empty:prisma db pull could not create any models in your schema.prisma file and you will not be able to generate Prisma Client with the prisma generate command.To fix this, you have two options:- manually create a table in your database.- make sure the database connection URL inside the datasource block in schema.prisma points to a database that is not empty (it must contain at least one table).Then you can run prisma db pull again.
✔ Introspected 3 models and wrote them into prisma/schema.prisma in 147ms*** WARNING ***The following fields had data stored in multiple types: - Model: "User", field: "metadata", chosen data type: "Json"Run prisma generate to generate Prisma Client.
Common warnings:
Mixed types: Fields with inconsistent data types
Unsupported types: Database types not supported by Prisma
Missing relations: Foreign keys without proper indexes
// Introspected without relationmodel Post { id Int author_id Int}// Add relationmodel Post { id Int @id authorId Int @map("author_id") author User @relation(fields: [authorId], references: [id])}
// Introspected as Stringmodel Product { id Int status String}// Use enumenum ProductStatus { DRAFT PUBLISHED ARCHIVED}model Product { id Int @id status ProductStatus @map("status")}