Skip to content

Commit e6053fe

Browse files
committed
Helper indices
1 parent 23ab3a4 commit e6053fe

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- Drop redundant single-column indexes now covered by composite indexes
2+
DROP INDEX IF EXISTS "email_address_idx";
3+
DROP INDEX IF EXISTS "user_status_idx";

prisma/schema.prisma

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ model email {
6161
user_email_xref user_email_xref[]
6262
user user? @relation("UserToEmail", fields: [user_id], references: [user_id], onDelete: NoAction, onUpdate: NoAction)
6363
64-
@@index([address])
6564
@@index([user_id, primary_ind], map: "email_user_id_idx")
65+
@@index([user_id, email_type_id, status_id])
66+
@@index([address, status_id])
6667
}
6768

6869
model email_status_lu {
@@ -176,7 +177,7 @@ model user {
176177
@@index([handle])
177178
@@index([handle_lower], map: "user_lower_handle_idx")
178179
@@index([open_id])
179-
@@index([status])
180+
@@index([status, handle_lower])
180181
}
181182

182183
model user_2fa {
@@ -249,6 +250,7 @@ model user_social_login {
249250
user user @relation(fields: [user_id], references: [user_id], onDelete: NoAction, onUpdate: NoAction, map: "user_social_user_fk")
250251
251252
@@id([user_id, social_login_provider_id], map: "user_social_prkey")
253+
@@index([social_user_id, social_login_provider_id])
252254
253255
}
254256

@@ -307,6 +309,7 @@ model user_email_xref {
307309
308310
@@id([user_id, email_id], map: "user_email_xref_pkey") // Define composite primary key
309311
@@index([email_id], map: "user_email_xref_email_idx")
312+
@@index([user_id, status_id])
310313
}
311314

312315

@@ -356,5 +359,6 @@ model RoleAssignment {
356359
@@unique([roleId, subjectId, subjectType], map: "role_subject_id_subject_type")
357360
@@index([subjectId], map: "subject_id_idx")
358361
@@index([roleId], map: "role_id_idx")
362+
@@index([subjectId, subjectType])
359363
@@map("role_assignment")
360364
}

0 commit comments

Comments
 (0)