mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 11:43:44 -05:00
4b9aa97ea1
Migrations: tag migrations with relevant environment GitOrigin-RevId: ad6c3bea19d3c21a1fdae58e09c861a3173c792b
26 lines
723 B
JavaScript
26 lines
723 B
JavaScript
const { getCollectionNames } = require('../../app/src/infrastructure/mongodb')
|
|
|
|
async function addIndexesToCollection(collection, indexes) {
|
|
return Promise.all(
|
|
indexes.map(index => {
|
|
index.background = true
|
|
return collection.createIndex(index.key, index)
|
|
})
|
|
)
|
|
}
|
|
|
|
async function dropIndexesFromCollection(collection, indexes) {
|
|
return Promise.all(indexes.map(index => collection.dropIndex(index.name)))
|
|
}
|
|
|
|
async function dropCollection(db, collectionName) {
|
|
const allCollections = await getCollectionNames()
|
|
if (!allCollections.includes(collectionName)) return
|
|
return db[collectionName].drop()
|
|
}
|
|
|
|
module.exports = {
|
|
addIndexesToCollection,
|
|
dropIndexesFromCollection,
|
|
dropCollection,
|
|
}
|