Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ME: Indices to composite foreign keys are impossible to create #567

Closed
pimeys opened this issue Mar 9, 2020 · 1 comment · Fixed by #576
Closed

ME: Indices to composite foreign keys are impossible to create #567

pimeys opened this issue Mar 9, 2020 · 1 comment · Fixed by #576
Assignees
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet.

Comments

@pimeys
Copy link
Contributor

pimeys commented Mar 9, 2020

Schema:

model User {
  id                  Int       @id
  firstName           String
  lastName            String
  @@unique([firstName, lastName])
}

Now we want to create another table that references the unique firstName/lastName combination in the User model, first try:

model SpamList {
  id   Int  @id
  user User @relation(references: [firstName, lastName])
  @@index([user])
}

errors:

reading the prisma schema from prisma/schema.prisma
Error: Failure during a migration command: Connector error. (error: Error querying the database: Error querying the database: Error querying the database: db error: ERROR: column "user" does not exist)

and another try:

model SpamList {
  id   Int  @id
  user User @relation(references: [firstName, lastName])

  @@index([user_firstName, user_lastName])
}

errors:

Error: Failure during a migration command: error: Error validating model "SpamList": The index definition refers to the unknown fields user_firstName, user_lastName.
  -->  schema.prisma:33
   |
32 |
33 |   @@index([user_firstName, user_lastName])
@pimeys pimeys added the bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. label Mar 9, 2020
@pimeys pimeys added this to the Preview 24 New milestone Mar 9, 2020
@janpio
Copy link
Member

janpio commented Mar 9, 2020

It's possible that it is currently not defined yet how these indexes in relation with composite FKs should actually be represented in the schema: prisma/prisma#1606

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants