Add migration for drop projectHistoryMetaData collection

GitOrigin-RevId: 1ebfc60ee9591837f37e507fb1dcb059c09a7f3b
This commit is contained in:
Andrew Rumble
2025-05-28 15:21:27 +01:00
committed by Copybot
parent f7fcf4c23f
commit 1386ca1669
2 changed files with 28 additions and 8 deletions
@@ -1,6 +1,7 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
import mongodb from '../app/src/infrastructure/mongodb.js'
const tags = ['saas']
@@ -13,17 +14,19 @@ const indexes = [
},
]
const migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.projectHistoryMetaData, indexes)
const migrate = async () => {
await Helpers.addIndexesToCollection(
await mongodb.getCollectionInternal('projectHistoryMetaData'),
indexes
)
}
const rollback = async client => {
const { db } = client
const rollback = async () => {
try {
await Helpers.dropIndexesFromCollection(db.projectHistoryMetaData, indexes)
await Helpers.dropIndexesFromCollection(
await mongodb.getCollectionInternal('projectHistoryMetaData'),
indexes
)
} catch (err) {
console.error('Something went wrong rolling back the migrations', err)
}
@@ -0,0 +1,17 @@
import Helpers from './lib/helpers.mjs'
const tags = ['saas']
const migrate = async () => {
await Helpers.dropCollection('projectHistoryMetaData')
}
const rollback = async () => {
// Can't really do anything here
}
export default {
tags,
migrate,
rollback,
}