Skip to content

Commit

Permalink
User database index
Browse files Browse the repository at this point in the history
  • Loading branch information
wxh06 committed Aug 24, 2023
1 parent 20b0503 commit 61320b7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .lintstagedrc.cjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
const eslint = "eslint --fix";
const prettier = "prettier --write";
const prettierCheck = "prettier --check";
const prisma = "prisma format --schema";

module.exports = {
"*.{js,mjs,cjs,jsx,ts,tsx}": [eslint, prettierCheck],
"*.{md,html,css,scss,json,yml,yaml}": prettier,
"*.prisma": prisma,
};
11 changes: 11 additions & 0 deletions prisma/migrations/20230824075523_user_index/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- CreateIndex
CREATE INDEX "Judgement_userId_idx" ON "Judgement"("userId");

-- CreateIndex
CREATE INDEX "Paste_userId_idx" ON "Paste"("userId");

-- CreateIndex
CREATE INDEX "Reply_authorId_idx" ON "Reply"("authorId");

-- CreateIndex
CREATE INDEX "Snapshot_authorId_idx" ON "Snapshot"("authorId");
5 changes: 5 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ model Snapshot {
@@id([discussionId, time])
@@index([discussionId])
@@index([authorId])
}

model Reply {
Expand All @@ -60,6 +61,7 @@ model Reply {
takedown ReplyTakedown?
@@index([discussionId])
@@index([authorId])
}

model DiscussionTakedown {
Expand All @@ -84,6 +86,8 @@ model Paste {
user User @relation(fields: [userId], references: [id])
userId Int
snapshots PasteSnapshot[]
@@index([userId])
}

model PasteSnapshot {
Expand All @@ -105,4 +109,5 @@ model Judgement {
@@id([time, userId])
@@index([time(sort: Desc)])
@@index([userId])
}

0 comments on commit 61320b7

Please sign in to comment.