I need help with my schema, it doesn’t let me migrate
Hello, I get this error when trying to migrate to my remote database:
Error: P3006
Migration
20240827190544_fix_relations
failed to apply cleanly to the shadow database.
Error:
ERROR: foreign key constraint "SubCategory_categoryId_fkey" cannot be implemented
DETAIL: Key columns "categoryId" and "id" are of incompatible types: text and uuid.
0: sql_schema_connector::validate_migrations
with namespaces=None
at schema-engine/connectors/sql-schema-connector/src/lib.rs:325
1: schema_core::state::DevDiagnostic
at schema-engine/core/src/state.rs:276
model Account {
id String @id @default(uuid()) @db.Uuid
name String
balance Float @default(0.0)
userId String @db.Uuid
user User @relation(fields: [userId], references: [id])
transactions Transaction[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([userId])
}
model Category {
id String @id @default(uuid()) @db.Uuid // Primary key
name String @unique // Unique index on the name
field
subCategories SubCategory[] // Relationship to SubCategory
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
transactions Transaction[]
description String? // Optional description field
@@index([name]) // Optional: Index on the name
field
}
i am barely new to prisma but I don’t understand what is wrong here2 Replies
Hey, do you have the model for SubCategory? It seems that the foreign key is not annotated with @db.Uuid.
Hi @Carlos 👋
What does your SubCategory model look like? Can you please share it?