Skip to content

Commit 0338ca3

Browse files
authored
use computed id for UserRepoData (#224)
1 parent 0303946 commit 0338ca3

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
Warnings:
3+
4+
- The primary key for the `UserRepoData` table will be changed. If it partially fails, the table could be left without primary key constraint.
5+
- You are about to drop the column `id` on the `UserRepoData` table. All the data in the column will be lost.
6+
7+
*/
8+
-- AlterTable
9+
ALTER TABLE "UserRepoData" DROP CONSTRAINT "UserRepoData_pkey",
10+
DROP COLUMN "id",
11+
ADD CONSTRAINT "UserRepoData_pkey" PRIMARY KEY ("userId", "repoId");

api/prisma/schema.prisma

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,15 @@ model User {
5353
}
5454

5555
model UserRepoData {
56-
id String @id
5756
user User @relation(fields: [userId], references: [id])
5857
userId String
5958
repo Repo @relation(fields: [repoId], references: [id])
6059
repoId String
6160
accessedAt DateTime @default(now()) @updatedAt
6261
dummyCount Int @default(0)
62+
63+
// use computed ID
64+
@@id([userId, repoId])
6365
}
6466

6567
model Repo {

0 commit comments

Comments
 (0)