|
@@ -1,10 +1,9 @@
|
|
|
/* eslint-disable no-unused-vars */
|
|
/* eslint-disable no-unused-vars */
|
|
|
|
|
|
|
|
-import Helpers from './lib/helpers.mjs'
|
|
|
|
|
-import mongodb from '../app/src/infrastructure/mongodb.js'
|
|
|
|
|
-const { getCollectionInternal } = mongodb
|
|
|
|
|
|
|
+const Helpers = require('./lib/helpers')
|
|
|
|
|
+const { getCollectionInternal } = require('../app/src/infrastructure/mongodb')
|
|
|
|
|
|
|
|
-const tags = ['saas']
|
|
|
|
|
|
|
+exports.tags = ['saas']
|
|
|
|
|
|
|
|
const indexes = [
|
|
const indexes = [
|
|
|
{
|
|
{
|
|
@@ -30,7 +29,7 @@ const indexes = [
|
|
|
]
|
|
]
|
|
|
|
|
|
|
|
// Export indexes for use in the fix-up migration 20220105130000_fix_saml_indexes.js.
|
|
// Export indexes for use in the fix-up migration 20220105130000_fix_saml_indexes.js.
|
|
|
-const samlLogsIndexes = indexes
|
|
|
|
|
|
|
+exports.samlLogsIndexes = indexes
|
|
|
|
|
|
|
|
async function getCollection() {
|
|
async function getCollection() {
|
|
|
// This collection was incorrectly named - it should have been `samlLogs`
|
|
// This collection was incorrectly named - it should have been `samlLogs`
|
|
@@ -39,12 +38,12 @@ async function getCollection() {
|
|
|
return await getCollectionInternal('samllog')
|
|
return await getCollectionInternal('samllog')
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-const migrate = async client => {
|
|
|
|
|
|
|
+exports.migrate = async client => {
|
|
|
const collection = await getCollection()
|
|
const collection = await getCollection()
|
|
|
await Helpers.addIndexesToCollection(collection, indexes)
|
|
await Helpers.addIndexesToCollection(collection, indexes)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-const rollback = async client => {
|
|
|
|
|
|
|
+exports.rollback = async client => {
|
|
|
const collection = await getCollection()
|
|
const collection = await getCollection()
|
|
|
try {
|
|
try {
|
|
|
await Helpers.dropIndexesFromCollection(collection, indexes)
|
|
await Helpers.dropIndexesFromCollection(collection, indexes)
|
|
@@ -52,10 +51,3 @@ const rollback = async client => {
|
|
|
console.error('Something went wrong rolling back the migrations', err)
|
|
console.error('Something went wrong rolling back the migrations', err)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-export default {
|
|
|
|
|
- tags,
|
|
|
|
|
- migrate,
|
|
|
|
|
- rollback,
|
|
|
|
|
- samlLogsIndexes,
|
|
|
|
|
-}
|
|
|