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