Skip to content

use computed id for UserRepoData #224

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

Merged
merged 1 commit into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
Warnings:

- The primary key for the `UserRepoData` table will be changed. If it partially fails, the table could be left without primary key constraint.
- You are about to drop the column `id` on the `UserRepoData` table. All the data in the column will be lost.

*/
-- AlterTable
ALTER TABLE "UserRepoData" DROP CONSTRAINT "UserRepoData_pkey",
DROP COLUMN "id",
ADD CONSTRAINT "UserRepoData_pkey" PRIMARY KEY ("userId", "repoId");
4 changes: 3 additions & 1 deletion api/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@ model User {
}

model UserRepoData {
id String @id
user User @relation(fields: [userId], references: [id])
userId String
repo Repo @relation(fields: [repoId], references: [id])
repoId String
accessedAt DateTime @default(now()) @updatedAt
dummyCount Int @default(0)

// use computed ID
@@id([userId, repoId])
}

model Repo {
Expand Down