2024-10-02 05:32:13 -04:00
|
|
|
import Helpers from './lib/helpers.mjs'
|
|
|
|
import mongodb from '../app/src/infrastructure/mongodb.js'
|
|
|
|
const { getCollectionInternal } = mongodb
|
2021-09-30 11:27:37 -04:00
|
|
|
|
2024-10-02 05:32:13 -04:00
|
|
|
const tags = ['saas']
|
2021-09-30 11:27:37 -04:00
|
|
|
|
|
|
|
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')
|
|
|
|
}
|
|
|
|
|
2024-10-02 05:32:13 -04:00
|
|
|
const 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
|
|
|
}
|
|
|
|
|
2024-10-02 05:32:13 -04:00
|
|
|
const 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
|
|
|
}
|
2024-10-02 05:32:13 -04:00
|
|
|
|
|
|
|
export default {
|
|
|
|
tags,
|
|
|
|
migrate,
|
|
|
|
rollback,
|
|
|
|
}
|