Skip to content

Commit b57f005

Browse files
committed
Add index for normalized sign-up email in ProjectUser model
- Introduced a new index on the ProjectUser model for the signUpEmailNormalized field, enhancing query performance related to user sign-up activities. - Updated the migration SQL to create the corresponding index in the database, ensuring efficient data retrieval for analytics and fraud protection measures.
1 parent d1b6564 commit b57f005

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

apps/backend/prisma/migrations/20260308000002_finalize_signup_fraud_protection/migration.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ CREATE INDEX CONCURRENTLY IF NOT EXISTS "ProjectUser_signUpIp_recent_idx"
1717
CREATE INDEX CONCURRENTLY IF NOT EXISTS "ProjectUser_signUpEmailBase_recent_idx"
1818
ON "ProjectUser"("tenancyId", "isAnonymous", "signUpEmailBase", "signedUpAt");
1919

20+
-- SPLIT_STATEMENT_SENTINEL
21+
-- SINGLE_STATEMENT_SENTINEL
22+
-- RUN_OUTSIDE_TRANSACTION_SENTINEL
23+
CREATE INDEX CONCURRENTLY IF NOT EXISTS "ProjectUser_signUpEmailNormalized_recent_idx"
24+
ON "ProjectUser"("tenancyId", "isAnonymous", "signUpEmailNormalized", "signedUpAt");
25+
2026
-- Validate the risk score bounds once every row has the new columns.
2127
-- SPLIT_STATEMENT_SENTINEL
2228
-- SINGLE_STATEMENT_SENTINEL

apps/backend/prisma/schema.prisma

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ model ProjectUser {
312312
@@index([tenancyId, createdAt(sort: Desc)], name: "ProjectUser_createdAt_desc")
313313
@@index([tenancyId, isAnonymous, signedUpAt(sort: Asc)], name: "ProjectUser_signedUpAt_asc")
314314
@@index([tenancyId, isAnonymous, signUpIp, signedUpAt], name: "ProjectUser_signUpIp_recent_idx")
315+
@@index([tenancyId, isAnonymous, signUpEmailNormalized, signedUpAt], name: "ProjectUser_signUpEmailNormalized_recent_idx")
315316
@@index([tenancyId, isAnonymous, signUpEmailBase, signedUpAt], name: "ProjectUser_signUpEmailBase_recent_idx")
316317
@@index([tenancyId, sequenceId], name: "ProjectUser_tenancyId_sequenceId_idx")
317318
@@index([shouldUpdateSequenceId, tenancyId], name: "ProjectUser_shouldUpdateSequenceId_idx")

0 commit comments

Comments
 (0)