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