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