server format
This commit is contained in:
1 parent
117a2e00c4
commit
e79bf28bdc
4 files changed
+16
-24
No files matched your search
@@ -19,10 +19,10 @@ const backupAndDropExistingCollection = async () => {
|
||||
return false;
|
||||
}
|
||||
|
||||
await db.collection(CHECKS_COLLECTION).aggregate([
|
||||
{ $match: {} },
|
||||
{ $out: BACKUP_COLLECTION },
|
||||
]).toArray();
|
||||
await db
|
||||
.collection(CHECKS_COLLECTION)
|
||||
.aggregate([{ $match: {} }, { $out: BACKUP_COLLECTION }])
|
||||
.toArray();
|
||||
await db.collection(CHECKS_COLLECTION).drop();
|
||||
return true;
|
||||
};
|
||||
@@ -40,12 +40,14 @@ const createTimeSeriesCollection = async () => {
|
||||
});
|
||||
}
|
||||
|
||||
await db.collection(CHECKS_COLLECTION).createIndexes([
|
||||
{ key: { updatedAt: 1 } },
|
||||
{ key: { "metadata.monitorId": 1, updatedAt: 1 } },
|
||||
{ key: { "metadata.monitorId": 1, updatedAt: -1 } },
|
||||
{ key: { "metadata.teamId": 1, updatedAt: -1 } },
|
||||
]);
|
||||
await db
|
||||
.collection(CHECKS_COLLECTION)
|
||||
.createIndexes([
|
||||
{ key: { updatedAt: 1 } },
|
||||
{ key: { "metadata.monitorId": 1, updatedAt: 1 } },
|
||||
{ key: { "metadata.monitorId": 1, updatedAt: -1 } },
|
||||
{ key: { "metadata.teamId": 1, updatedAt: -1 } },
|
||||
]);
|
||||
};
|
||||
|
||||
const migrateBackupData = async () => {
|
||||
|
||||
@@ -32,11 +32,7 @@ const runMigrations = async (logger?: { info: Function; error: Function }) => {
|
||||
logger?.info({ message: `Completed ${migration.name}`, service: "Migrations" });
|
||||
} catch (error) {
|
||||
const err = error as Error;
|
||||
await MigrationModel.findOneAndUpdate(
|
||||
{ name: migration.name },
|
||||
{ status: "failed", error: err?.message },
|
||||
{ upsert: true }
|
||||
);
|
||||
await MigrationModel.findOneAndUpdate({ name: migration.name }, { status: "failed", error: err?.message }, { upsert: true });
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user