Awey
11/16/2021, 6:47 AMmodel Follows {
createdAt DateTime @default(now())
follower User @relation("follower", fields: [followerId], references: [id])
followerId Int
following User @relation("following", fields: [followingId], references: [id])
followingId Int
@@id([followerId, followingId])
}
I want make sure followerId and followingId can never be the same.Ryan
11/16/2021, 6:52 AMRyan
11/16/2021, 6:54 AMAwey
11/16/2021, 7:01 AM20211116063937_init/migration.sql
Ryan
11/16/2021, 7:05 AMprisma migrate dev --create-only
2. Edit the generated .sql
file and add the constraint
3. Apply the migration using prisma migrate dev
Awey
11/16/2021, 7:41 AMALTER TABLE follows
ADD CHECK (follower_id <> following_id);
Works perfectly, thanks for the help @Ryan