Skip to content

Commit 5b98e94

Browse files
committed
refactor(db): Remove redundant index dropping logic from createOptimalIndexes function
1 parent 3fb97b2 commit 5b98e94

File tree

2 files changed

+1
-21
lines changed

2 files changed

+1
-21
lines changed

.github/workflows/deploy-server.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
3838
AWS_DEFAULT_REGION: ap-south-1
3939
MONGO_URI: ${{ secrets.MONGO_URI }}
40+
REDIS_URL: ${{ secrets.REDIS_URL }}
4041
BASE_URL: ${{ secrets.BASE_URL }}
4142
CLIENT_URL: ${{ secrets.CLIENT_URL }}
4243
JWT_SECRET: ${{ secrets.JWT_SECRET }}

server/lib/dbIndexes.js

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,6 @@ export const createOptimalIndexes = async () => {
88
const usersCollection = mongoose.connection.db.collection('users');
99
const challengesCollection = mongoose.connection.db.collection('challenges');
1010

11-
// Drop problematic indexes individually
12-
try {
13-
// Drop known problematic indexes
14-
const problematicIndexes = [
15-
'username_1', 'email_1', 'UserTextIndex', 'ChallengeTextIndex',
16-
'email_unique_idx', 'username_unique_idx', 'regno_unique_idx',
17-
'challenge_search_idx', 'leaderboard_sort_idx'
18-
];
19-
20-
for (const indexName of problematicIndexes) {
21-
try {
22-
await usersCollection.dropIndex(indexName);
23-
} catch (e) { /* Index doesn't exist */ }
24-
try {
25-
await challengesCollection.dropIndex(indexName);
26-
} catch (e) { /* Index doesn't exist */ }
27-
}
28-
} catch (error) {
29-
// Continue anyway
30-
}
31-
3211
// Wait for drops to complete
3312
await new Promise(resolve => setTimeout(resolve, 1000));
3413

0 commit comments

Comments
 (0)