2021-09-30 15:27:37 +00:00
|
|
|
const Helpers = require('./lib/helpers')
|
2022-01-10 11:36:18 +00:00
|
|
|
const { getCollectionInternal } = require('../app/src/infrastructure/mongodb')
|
2021-09-30 15:27:37 +00:00
|
|
|
|
|
|
|
exports.tags = ['saas']
|
|
|
|
|
|
|
|
const indexes = [
|
|
|
|
{
|
|
|
|
key: {
|
|
|
|
name: 1,
|
|
|
|
},
|
|
|
|
unique: true,
|
|
|
|
name: 'name_1',
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
2022-01-10 11:36:18 +00:00
|
|
|
async function getCollection() {
|
|
|
|
// NOTE: We do not access the splittests collection directly. Fetch it here.
|
|
|
|
return await getCollectionInternal('splittests')
|
|
|
|
}
|
|
|
|
|
2021-09-30 15:27:37 +00:00
|
|
|
exports.migrate = async client => {
|
2022-01-10 11:36:18 +00:00
|
|
|
const collection = await getCollection()
|
|
|
|
await Helpers.addIndexesToCollection(collection, indexes)
|
2021-09-30 15:27:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
exports.rollback = async client => {
|
2022-01-10 11:36:18 +00:00
|
|
|
const collection = await getCollection()
|
|
|
|
await Helpers.dropIndexesFromCollection(collection, indexes)
|
2021-09-30 15:27:37 +00:00
|
|
|
}
|