overleaf/services/web/migrations/20210924140139_splittests-name-index.js

30 lines
700 B
JavaScript
Raw Normal View History

const Helpers = require('./lib/helpers')
const { getCollectionInternal } = require('../app/src/infrastructure/mongodb')
exports.tags = ['saas']
const indexes = [
{
key: {
name: 1,
},
unique: true,
name: 'name_1',
},
]
async function getCollection() {
// NOTE: We do not access the splittests collection directly. Fetch it here.
return await getCollectionInternal('splittests')
}
exports.migrate = async client => {
const collection = await getCollection()
await Helpers.addIndexesToCollection(collection, indexes)
}
exports.rollback = async client => {
const collection = await getCollection()
await Helpers.dropIndexesFromCollection(collection, indexes)
}