Skip to content

Commit 428319d

Browse files
committed
fix
1 parent 00f8d4c commit 428319d

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

8.0.0.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ This document only highlights specific changes that require a longer explanation
55
---
66

77
- [Email Verification](#email-verification)
8+
- [Database Indexes](#database-indexes)
89

910
---
1011

@@ -25,3 +26,15 @@ The request to re-send a verification email changed to sending a `POST` request
2526
Related pull requests:
2627

2728
- https://github.com/parse-community/parse-server/pull/8488
29+
30+
## Database Indexes
31+
32+
As part of the email verification and password reset improvements in Parse Server 8, the queries used for these operations have changed to use tokens instead of username/email fields. To ensure optimal query performance, Parse Server now automatically creates indexes on the following fields during server initialization:
33+
34+
- `_User._email_verify_token`: used for email verification queries
35+
- `_User._perishable_token`: used for password reset queries
36+
37+
These indexes are created automatically when Parse Server starts, similar to how indexes for `username` and `email` fields are created. No manual intervention is required.
38+
39+
> [!WARNING]
40+
> If you have a large existing user base, the index creation may take some time during the first server startup after upgrading to Parse Server 8. The server logs will indicate when index creation is complete or if any errors occur. If you have any concerns regarding a potential database performance impact during index creation, you could create these indexes manually in a controlled procedure before upgrading Parse Server.

src/Controllers/DatabaseController.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1764,6 +1764,20 @@ class DatabaseController {
17641764
throw error;
17651765
});
17661766

1767+
await this.adapter
1768+
.ensureIndex('_User', requiredUserFields, ['_email_verify_token'], '_email_verify_token', false)
1769+
.catch(error => {
1770+
logger.warn('Unable to create index for email verification token: ', error);
1771+
throw error;
1772+
});
1773+
1774+
await this.adapter
1775+
.ensureIndex('_User', requiredUserFields, ['_perishable_token'], '_perishable_token', false)
1776+
.catch(error => {
1777+
logger.warn('Unable to create index for password reset token: ', error);
1778+
throw error;
1779+
});
1780+
17671781
await this.adapter.ensureUniqueness('_Role', requiredRoleFields, ['name']).catch(error => {
17681782
logger.warn('Unable to ensure uniqueness for role name: ', error);
17691783
throw error;

0 commit comments

Comments
 (0)