dedupe monitor stats, run migrations before index creation
This commit is contained in:
1 parent
0fcb38f7e6
commit
e1b00ce735
3 files changed
+86
-2
No files matched your search
@@ -35,6 +35,12 @@ class MongoDB implements IDb {
|
||||
setDefaultsOnInsert: true,
|
||||
}
|
||||
);
|
||||
// Run migrations BEFORE syncIndexes. The 0006 dedupe migration must run before
|
||||
// the unique index on MonitorStats.monitorId is enforced, otherwise databases
|
||||
// with stray duplicates (caused by the pre-fix race in updateRunningStats)
|
||||
// will crash at startup when the unique index fails to build.
|
||||
await runMigrations();
|
||||
|
||||
// Sync indexes
|
||||
const models = mongoose.modelNames();
|
||||
for (const modelName of models) {
|
||||
@@ -47,8 +53,6 @@ class MongoDB implements IDb {
|
||||
service: SERVICE_NAME,
|
||||
method: "connect",
|
||||
});
|
||||
|
||||
await runMigrations();
|
||||
} catch (error: unknown) {
|
||||
this.logger.error({
|
||||
message: error instanceof Error ? error.message : "Unknown error",
|
||||
|
||||
Reference in new issue
Block a user