|
| 1 | +import 'package:ht_api/src/services/mongodb_token_blacklist_service.dart'; |
| 2 | +import 'package:ht_api/src/services/mongodb_verification_code_storage_service.dart'; |
1 | 3 | import 'package:ht_shared/ht_shared.dart'; |
2 | 4 | import 'package:logging/logging.dart'; |
3 | 5 | import 'package:mongo_dart/mongo_dart.dart'; |
@@ -143,6 +145,35 @@ class DatabaseSeedingService { |
143 | 145 | name: 'sources_text_index', |
144 | 146 | ); |
145 | 147 |
|
| 148 | + // Indexes for the verification codes collection |
| 149 | + await _db.runCommand({ |
| 150 | + 'createIndexes': kVerificationCodesCollection, |
| 151 | + 'indexes': [ |
| 152 | + { |
| 153 | + 'key': {'expiresAt': 1}, |
| 154 | + 'name': 'expiresAt_ttl_index', |
| 155 | + 'expireAfterSeconds': 0, |
| 156 | + }, |
| 157 | + { |
| 158 | + 'key': {'email': 1}, |
| 159 | + 'name': 'email_unique_index', |
| 160 | + 'unique': true, |
| 161 | + } |
| 162 | + ] |
| 163 | + }); |
| 164 | + |
| 165 | + // Index for the token blacklist collection |
| 166 | + await _db.runCommand({ |
| 167 | + 'createIndexes': kBlacklistedTokensCollection, |
| 168 | + 'indexes': [ |
| 169 | + { |
| 170 | + 'key': {'expiry': 1}, |
| 171 | + 'name': 'expiry_ttl_index', |
| 172 | + 'expireAfterSeconds': 0, |
| 173 | + } |
| 174 | + ] |
| 175 | + }); |
| 176 | + |
146 | 177 | _log.info('Database indexes are set up correctly.'); |
147 | 178 | } on Exception catch (e, s) { |
148 | 179 | _log.severe('Failed to create database indexes.', e, s); |
|
0 commit comments