relation for borth friend
See original GitHub issueBug description
firend table has two userid
How to reproduce
Run ‘export DEBUG=“*” && npx prisma migrate dev --preview-feature’ See error
Expected behavior
Error: Error: Database error: Error querying the database: Server error: `ERROR HY000 (1822): Failed to add the foreign key constraint. Missing index for constraint 'friends_ibfk_1' in the referenced table 'Users''
0: migration_core::api::ApplyMigrations
at migration-engine/core/src/api.rs:102
Prisma information
// This is your Prisma schema file, // learn more about it in the docs: https://pris.ly/d/prisma-schema
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
model Users {
id Int @id @default(autoincrement())
name String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
Friends Friends[]
}
model Friends {
id Int @id @default(autoincrement())
userId Int
friendUserId Int
Users Users @relation(fields: [userId, friendUserId], references: [id, id])
status Boolean @default(true)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
Environment & setup
- OS:
macOS 10.15.7
- Database:
MySQL
- Node.js version:
v14.0.0
- Prisma version:
@prisma/cli : 2.13.0
@prisma/client : 2.13.0
@prisma/cli : 2.13.1
@prisma/client : 2.13.1
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
How To Support Your Friend Who Just Had a Baby
Some of this depends on your relationship with the person as well; know your friend might be sensitive about ANYONE holding his or...
Read more >How To Go From "Friends" To "Officially Dating" - YouTube
Hi Youtube, I'm Amy North. I'm a relationship specialist and it's my mission to help women find the love they want and deserve....
Read more >AITA for wanting to be a part of my best friends birth - Reddit
Your friend wants you there because she needs you and wants you to be part of her journey. It's for her to decide,...
Read more >The Loneliness of Early Parenthood - The Atlantic
After all, “similarity breeds friendship by forming a basis for conversation and joint activities,” argue the Dutch researchers in their study.
Read more >Friends: What Happened To Phoebe's Birth Mother
Phoebe Abbott was a close friend of Lily and Frank Buffay, Phoebe's father. The three were in a relationship which led to Phoebe...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The following model creates the required tables:
You can also introspect(https://www.prisma.io/docs/concepts/components/introspection) the database if you are more comfortable in writing the schema in sql first.
@janpio ok