Merge pull request #20731 from overleaf/revert-20480-ls-convert-migration-scripts-to-esm

Revert "Convert migration scripts to ESM"

GitOrigin-RevId: ca9ddda6ddee8964f72797d3b653ef9cee6a7a49
This commit is contained in:
Liangjun Song 2024-10-01 17:53:36 +08:00 committed by Copybot
parent 492fe24a75
commit b69ff9417a
126 changed files with 557 additions and 1202 deletions

View file

@ -1,5 +1,4 @@
{
"adapter": "./migrations/lib/adapter.mjs",
"migrationNumberFormat": "dateTime",
"migrationExtension": "mjs"
"adapter": "./migrations/lib/adapter",
"migrationNumberFormat": "dateTime"
}

View file

@ -1,10 +1,10 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['server-ce', 'server-pro', 'saas']
exports.tags = ['server-ce', 'server-pro', 'saas']
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.migrations, [
{
@ -14,7 +14,7 @@ const migrate = async client => {
])
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
try {
@ -23,9 +23,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -8,21 +8,15 @@
* or "hello <name>", when User.findOne() finds something.
*/
import runScript from '../scripts/example/script_for_migration.js'
const runScript = require('../scripts/example/script_for_migration.js')
const tags = []
exports.tags = []
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await runScript()
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['server-ce', 'server-pro', 'saas']
exports.tags = ['server-ce', 'server-pro', 'saas']
const indexes = [
{
@ -14,13 +14,13 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.contacts, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
try {
@ -29,9 +29,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['server-ce', 'server-pro', 'saas']
exports.tags = ['server-ce', 'server-pro', 'saas']
const indexes = [
{
@ -19,13 +19,13 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.deletedProjects, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
try {
@ -34,9 +34,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['saas']
exports.tags = ['saas']
const indexes = [
{
@ -20,13 +20,13 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.deletedSubscriptions, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
try {
@ -35,9 +35,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['server-ce', 'server-pro', 'saas']
exports.tags = ['server-ce', 'server-pro', 'saas']
const indexes = [
{
@ -13,13 +13,13 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.docHistoryIndex, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
try {
@ -28,9 +28,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['server-ce', 'server-pro', 'saas']
exports.tags = ['server-ce', 'server-pro', 'saas']
const indexes = [
{
@ -41,13 +41,13 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.docHistory, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
try {
@ -56,9 +56,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,6 +1,6 @@
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['server-ce', 'server-pro', 'saas']
exports.tags = ['server-ce', 'server-pro', 'saas']
const indexes = [
{
@ -12,18 +12,12 @@ const indexes = [
},
]
const migrate = async ({ nativeDb }) => {
exports.migrate = async ({ nativeDb }) => {
const docOps = nativeDb.collection('docOps')
await Helpers.addIndexesToCollection(docOps, indexes)
}
const rollback = async ({ nativeDb }) => {
exports.rollback = async ({ nativeDb }) => {
const docOps = nativeDb.collection('docOps')
await Helpers.dropIndexesFromCollection(docOps, indexes)
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['server-ce', 'server-pro', 'saas']
exports.tags = ['server-ce', 'server-pro', 'saas']
const indexes = [
{
@ -20,13 +20,13 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.docSnapshots, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
try {
@ -35,9 +35,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['server-ce', 'server-pro', 'saas']
exports.tags = ['server-ce', 'server-pro', 'saas']
const indexes = [
{
@ -13,13 +13,13 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.docs, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
try {
@ -28,9 +28,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['saas']
exports.tags = ['saas']
const indexes = [
{
@ -21,13 +21,13 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.githubSyncEntityVersions, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
try {
@ -39,9 +39,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['saas']
exports.tags = ['saas']
const indexes = [
{
@ -19,13 +19,13 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.githubSyncProjectStates, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
try {
@ -34,9 +34,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['saas']
exports.tags = ['saas']
const indexes = [
{
@ -13,13 +13,13 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.githubSyncUserCredentials, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
try {
@ -31,9 +31,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['saas']
exports.tags = ['saas']
const indexes = [
{
@ -14,13 +14,13 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.institutions, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
try {
@ -29,9 +29,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['server-ce', 'server-pro', 'saas']
exports.tags = ['server-ce', 'server-pro', 'saas']
const indexes = [
{
@ -14,13 +14,13 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.messages, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
try {
@ -29,9 +29,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['server-ce', 'server-pro', 'saas']
exports.tags = ['server-ce', 'server-pro', 'saas']
const indexes = [
{
@ -26,13 +26,13 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.notifications, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
try {
@ -41,9 +41,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['saas']
exports.tags = ['saas']
const indexes = [
{
@ -21,13 +21,13 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.oauthAccessTokens, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
try {
@ -36,9 +36,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['saas']
exports.tags = ['saas']
const indexes = [
{
@ -14,13 +14,13 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.oauthApplications, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
try {
@ -29,9 +29,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['saas']
exports.tags = ['saas']
const indexes = [
{
@ -14,13 +14,13 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.oauthAuthorizationCodes, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
try {
@ -29,9 +29,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['saas']
exports.tags = ['saas']
const indexes = [
{
@ -13,13 +13,13 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.projectHistoryFailures, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
try {
@ -28,9 +28,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['saas']
exports.tags = ['saas']
const indexes = [
{
@ -19,13 +19,13 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.projectHistoryLabels, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
try {
@ -34,9 +34,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['saas']
exports.tags = ['saas']
const indexes = [
{
@ -13,13 +13,13 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.projectHistoryMetaData, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
try {
@ -28,9 +28,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['saas']
exports.tags = ['saas']
const indexes = [
{
@ -20,13 +20,13 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.projectHistorySyncState, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
try {
@ -35,9 +35,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,10 +1,9 @@
/* 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 = [
{
@ -20,12 +19,12 @@ async function getCollection() {
return await getCollectionInternal('projectImportFailures')
}
const migrate = async client => {
exports.migrate = async client => {
const collection = await getCollection()
await Helpers.addIndexesToCollection(collection, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const collection = await getCollection()
try {
await Helpers.dropIndexesFromCollection(collection, indexes)
@ -33,9 +32,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['server-ce', 'server-pro', 'saas']
exports.tags = ['server-ce', 'server-pro', 'saas']
const indexes = [
{
@ -20,13 +20,13 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.projectInvites, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
try {
@ -35,9 +35,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['server-ce', 'server-pro', 'saas']
exports.tags = ['server-ce', 'server-pro', 'saas']
const indexes = [
{
@ -123,13 +123,13 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.projects, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
try {
@ -138,9 +138,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['saas']
exports.tags = ['saas']
const indexes = [
{
@ -14,13 +14,13 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.publishers, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
try {
@ -29,9 +29,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['server-ce', 'server-pro', 'saas']
exports.tags = ['server-ce', 'server-pro', 'saas']
const indexes = [
{
@ -13,13 +13,13 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.rooms, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
try {
@ -28,9 +28,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['server-ce', 'server-pro', 'saas']
exports.tags = ['server-ce', 'server-pro', 'saas']
const indexes = [
{
@ -13,13 +13,13 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.spellingPreferences, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
try {
@ -28,9 +28,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['saas']
exports.tags = ['saas']
const indexes = [
{
@ -68,13 +68,13 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.subscriptions, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
try {
@ -83,9 +83,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['server-ce', 'server-pro', 'saas']
exports.tags = ['server-ce', 'server-pro', 'saas']
const indexes = [
{
@ -21,13 +21,13 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.tags, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
try {
@ -36,9 +36,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['server-pro', 'saas']
exports.tags = ['server-pro', 'saas']
const indexes = [
{
@ -26,13 +26,13 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.templates, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
try {
@ -41,9 +41,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['server-ce', 'server-pro', 'saas']
exports.tags = ['server-ce', 'server-pro', 'saas']
const indexes = [
{
@ -15,13 +15,13 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.tokens, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
try {
@ -30,9 +30,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['server-ce', 'server-pro', 'saas']
exports.tags = ['server-ce', 'server-pro', 'saas']
const indexes = [
{
@ -147,13 +147,13 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.users, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
try {
@ -162,9 +162,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['saas']
exports.tags = ['saas']
const indexes = [
{
@ -13,13 +13,13 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.userstubs, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
try {
@ -28,9 +28,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

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

View file

@ -1,10 +1,9 @@
/* 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 = [
{
@ -18,7 +17,7 @@ const indexes = [
]
// Export indexes for use in the fix-up migration 20220105130000_fix_saml_indexes.js.
const usersIndexes = indexes
exports.usersIndexes = indexes
async function getCollection() {
// This collection was incorrectly named - it should have been `users` instead
@ -27,12 +26,12 @@ async function getCollection() {
return await getCollectionInternal('user')
}
const migrate = async client => {
exports.migrate = async client => {
const collection = await getCollection()
await Helpers.addIndexesToCollection(collection, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const collection = await getCollection()
try {
await Helpers.dropIndexesFromCollection(collection, indexes)
@ -40,10 +39,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
usersIndexes,
}

View file

@ -1,6 +1,6 @@
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['saas']
exports.tags = ['saas']
const indexes = [
{
@ -11,20 +11,14 @@ const indexes = [
},
]
const migrate = async ({ db }) => {
exports.migrate = async ({ db }) => {
await Helpers.addIndexesToCollection(db.projects, indexes)
}
const rollback = async ({ db }) => {
exports.rollback = async ({ db }) => {
try {
await Helpers.dropIndexesFromCollection(db.projects, indexes)
} catch (err) {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['server-ce', 'server-pro', 'saas']
exports.tags = ['server-ce', 'server-pro', 'saas']
const indexes = {
docSnapshots: [{ key: { project_id: 1, ts: 1 }, name: 'project_id_1_ts_1' }],
@ -15,7 +15,7 @@ const indexes = {
docs: [{ key: { project_id: 1, inS3: 1 }, name: 'project_id_1_inS3_1' }],
}
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Promise.all(
@ -25,7 +25,7 @@ const migrate = async client => {
)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
await Promise.all(
@ -34,9 +34,3 @@ const rollback = async client => {
)
)
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,6 +1,6 @@
/* eslint-disable no-unused-vars */
const tags = ['server-ce', 'server-pro', 'saas']
exports.tags = ['server-ce', 'server-pro', 'saas']
async function removeDuplicates(collection, field) {
const duplicates = await collection.aggregate(
@ -31,18 +31,12 @@ async function removeDuplicates(collection, field) {
}
}
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await removeDuplicates(db.deletedProjects, 'deletedProjectId')
await removeDuplicates(db.deletedUsers, 'deletedUserId')
}
const rollback = async client => {
exports.rollback = async client => {
// can't really do anything here
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,10 +1,10 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['server-ce', 'server-pro', 'saas']
exports.tags = ['server-ce', 'server-pro', 'saas']
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
// deletedUsers did not have an index before
await Helpers.dropIndexesFromCollection(db.deletedProjects, [
@ -37,7 +37,7 @@ const migrate = async client => {
])
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
await Helpers.dropIndexesFromCollection(db.deletedProjects, [
{
@ -68,9 +68,3 @@ const rollback = async client => {
])
// deletedUsers did not have an index before
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
exports.tags = ['saas']
const tags = ['saas']
const Helpers = require('./lib/helpers')
const indexes = [
{
@ -14,18 +14,12 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.users, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
await Helpers.dropIndexesFromCollection(db.users, indexes)
}
export default {
tags,
migrate,
rollback,
}

View file

@ -0,0 +1,11 @@
const Helpers = require('./lib/helpers')
exports.tags = ['saas']
exports.migrate = async client => {
await Helpers.dropCollection('projectImportFailures')
}
exports.rollback = async client => {
// can't really do anything here
}

View file

@ -1,17 +0,0 @@
import Helpers from './lib/helpers.mjs'
const tags = ['saas']
const migrate = async client => {
await Helpers.dropCollection('projectImportFailures')
}
const rollback = async client => {
// can't really do anything here
}
export default {
tags,
migrate,
rollback,
}

View file

@ -0,0 +1,11 @@
const Helpers = require('./lib/helpers')
exports.tags = ['saas']
exports.migrate = async client => {
await Helpers.dropCollection('projectImportBatchRecords')
}
exports.rollback = async client => {
// can't really do anything here
}

View file

@ -1,17 +0,0 @@
import Helpers from './lib/helpers.mjs'
const tags = ['saas']
const migrate = async client => {
await Helpers.dropCollection('projectImportBatchRecords')
}
const rollback = async client => {
// can't really do anything here
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['saas']
exports.tags = ['saas']
const indexes = [
{
@ -21,13 +21,13 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.samlCache, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
try {
@ -36,9 +36,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['saas']
exports.tags = ['saas']
const oldIndex = {
unique: true,
@ -25,14 +25,14 @@ const newIndex = {
sparse: true,
}
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.dropIndexesFromCollection(db.subscriptions, [oldIndex])
await Helpers.addIndexesToCollection(db.subscriptions, [newIndex])
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
try {
@ -42,9 +42,3 @@ const rollback = async client => {
console.error('Something went wrong rolling back the migrations', err)
}
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,6 +1,6 @@
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['server-ce', 'server-pro', 'saas']
exports.tags = ['server-ce', 'server-pro', 'saas']
const index = {
key: { _id: 1, lastOpened: 1, active: 1 },
@ -10,18 +10,12 @@ const index = {
},
}
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.projects, [index])
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
await Helpers.dropIndexesFromCollection(db.projects, [index])
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,6 +1,6 @@
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['server-ce', 'server-pro', 'saas']
exports.tags = ['server-ce', 'server-pro', 'saas']
const indexes = [
{
@ -11,18 +11,12 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.deletedFiles, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
await Helpers.dropIndexesFromCollection(db.deletedFiles, indexes)
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,6 +1,6 @@
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['server-ce', 'server-pro', 'saas']
exports.tags = ['server-ce', 'server-pro', 'saas']
const indexes = {
tokens: [
@ -15,7 +15,7 @@ const indexes = {
],
}
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Promise.all(
@ -25,7 +25,7 @@ const migrate = async client => {
)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
await Promise.all(
@ -34,9 +34,3 @@ const rollback = async client => {
)
)
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,6 +1,6 @@
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['server-ce', 'server-pro', 'saas']
exports.tags = ['server-ce', 'server-pro', 'saas']
const indexes = [
{
@ -13,18 +13,12 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.docs, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
await Helpers.dropIndexesFromCollection(db.docs, indexes)
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,6 +1,6 @@
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['saas']
exports.tags = ['saas']
const indexes = [
{
@ -11,18 +11,12 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.projects, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
await Helpers.dropIndexesFromCollection(db.projects, indexes)
}
export default {
tags,
migrate,
rollback,
}

View file

@ -0,0 +1,11 @@
const updateStringDates = require('../scripts/confirmed_at_to_dates.js')
exports.tags = ['saas']
exports.migrate = async client => {
await updateStringDates()
}
exports.rollback = async client => {
/* nothing to do */
}

View file

@ -1,17 +0,0 @@
import updateStringDates from '../scripts/confirmed_at_to_dates.js'
const tags = ['saas']
const migrate = async client => {
await updateStringDates()
}
const rollback = async client => {
/* nothing to do */
}
export default {
tags,
migrate,
rollback,
}

View file

@ -0,0 +1,11 @@
const updateStringDates = require('../scripts/split_tests_assigned_at_to_dates')
exports.tags = ['saas']
exports.migrate = async client => {
await updateStringDates()
}
exports.rollback = async client => {
/* nothing to do */
}

View file

@ -1,17 +0,0 @@
import updateStringDates from '../scripts/confirmed_at_to_dates.js'
const tags = ['saas']
const migrate = async client => {
await updateStringDates()
}
const rollback = async client => {
/* nothing to do */
}
export default {
tags,
migrate,
rollback,
}

View file

@ -0,0 +1,14 @@
const runScript = require('../scripts/back_fill_deleted_files.js')
exports.tags = ['server-ce', 'server-pro', 'saas']
exports.migrate = async client => {
const options = {
performCleanup: true,
letUserDoubleCheckInputsFor: 10,
fixPartialInserts: true,
}
await runScript(options)
}
exports.rollback = async client => {}

View file

@ -1,20 +0,0 @@
import runScript from '../scripts/back_fill_deleted_files.js'
const tags = ['server-ce', 'server-pro', 'saas']
const migrate = async client => {
const options = {
performCleanup: true,
letUserDoubleCheckInputsFor: 10,
fixPartialInserts: true,
}
await runScript(options)
}
const rollback = async client => {}
export default {
tags,
migrate,
rollback,
}

View file

@ -0,0 +1,13 @@
const runScript = require('../scripts/back_fill_doc_name_for_deleted_docs.js')
exports.tags = ['server-ce', 'server-pro', 'saas']
exports.migrate = async client => {
const options = {
performCleanup: true,
letUserDoubleCheckInputsFor: 10,
}
await runScript(options)
}
exports.rollback = async client => {}

View file

@ -1,19 +0,0 @@
import runScript from '../scripts/back_fill_doc_name_for_deleted_docs.js'
const tags = ['server-ce', 'server-pro', 'saas']
const migrate = async client => {
const options = {
performCleanup: true,
letUserDoubleCheckInputsFor: 10,
}
await runScript(options)
}
const rollback = async client => {}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
import runScript from '../scripts/back_fill_dummy_doc_meta.js'
const runScript = require('../scripts/back_fill_dummy_doc_meta.js')
const tags = ['server-ce', 'server-pro', 'saas']
exports.tags = ['server-ce', 'server-pro', 'saas']
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
const [firstProject] = await db.projects
.find()
@ -20,10 +20,4 @@ const migrate = async client => {
await runScript(options)
}
const rollback = async client => {}
export default {
tags,
migrate,
rollback,
}
exports.rollback = async client => {}

View file

@ -1,8 +1,7 @@
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 = [
{
@ -19,18 +18,12 @@ async function getCollection() {
return await getCollectionInternal('splittests')
}
const migrate = async client => {
exports.migrate = async client => {
const collection = await getCollection()
await Helpers.addIndexesToCollection(collection, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const collection = await getCollection()
await Helpers.dropIndexesFromCollection(collection, indexes)
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,6 +1,6 @@
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['saas']
exports.tags = ['saas']
const unusedCollections = [
'collaberatorcount',
@ -18,18 +18,12 @@ const unusedCollections = [
'usersEmailDomains',
]
const migrate = async () => {
exports.migrate = async () => {
for (const name of unusedCollections) {
await Helpers.dropCollection(name)
}
}
const rollback = async () => {
exports.rollback = async () => {
// We lost the indexes. There is no way back.
}
export default {
tags,
migrate,
rollback,
}

View file

@ -0,0 +1,19 @@
const Helpers = require('./lib/helpers')
const { samlLogsIndexes } = require('./20191106102104_saml-log-indexes')
const { usersIndexes } = require('./20191107191318_saml-indentifiers-index')
exports.tags = ['saas']
exports.migrate = async ({ db }) => {
// Fix-up the previous SAML migrations that were operating on collections with
// typos in their names.
await Helpers.addIndexesToCollection(
db.users,
usersIndexes.map(index => {
return Object.assign({}, index, { unique: true })
})
)
await Helpers.addIndexesToCollection(db.samlLogs, samlLogsIndexes)
}
exports.rollback = async () => {}

View file

@ -1,28 +0,0 @@
import Helpers from './lib/helpers.mjs'
import SamlLogsIndexesMigration from './20191106102104_saml-log-indexes.mjs'
import SamlIndentifiersIndexMigration from './20191107191318_saml-indentifiers-index.mjs'
const { samlLogsIndexes } = SamlLogsIndexesMigration
const { usersIndexes } = SamlIndentifiersIndexMigration
const tags = ['saas']
const migrate = async ({ db }) => {
// Fix-up the previous SAML migrations that were operating on collections with
// typos in their names.
await Helpers.addIndexesToCollection(
db.users,
usersIndexes.map(index => {
return Object.assign({}, index, { unique: true })
})
)
await Helpers.addIndexesToCollection(db.samlLogs, samlLogsIndexes)
}
const rollback = async () => {}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,6 +1,6 @@
const tags = ['saas']
exports.tags = ['saas']
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await db.splittests.updateMany(
{},
@ -28,7 +28,7 @@ const migrate = async client => {
)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
await db.splittests.updateMany(
{},
@ -49,9 +49,3 @@ const rollback = async client => {
}
)
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,6 +1,6 @@
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['saas']
exports.tags = ['saas']
const indexes = [
{
@ -11,18 +11,12 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.dropboxEntities, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
await Helpers.dropIndexesFromCollection(db.dropboxEntities, indexes)
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,6 +1,6 @@
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['saas']
exports.tags = ['saas']
const indexes = [
{
@ -13,18 +13,12 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.dropboxProjects, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
await Helpers.dropIndexesFromCollection(db.dropboxProjects, indexes)
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,6 +1,6 @@
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['saas']
exports.tags = ['saas']
const indexes = [
{
@ -13,18 +13,12 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.dropboxProjects, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
await Helpers.dropIndexesFromCollection(db.dropboxProjects, indexes)
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,6 +1,6 @@
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['saas']
exports.tags = ['saas']
const indexes = [
{
@ -18,7 +18,7 @@ const indexes = [
{ key: { 'overleaf.userId': 1, 'dropbox.pathLower': 'hashed' } },
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
// Forcibly drop the dropboxEntities collection. The new structure is
// different and we don't want to keep the data with the old structure around.
@ -26,13 +26,7 @@ const migrate = async client => {
await Helpers.addIndexesToCollection(db.dropboxEntities, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
await Helpers.dropIndexesFromCollection(db.dropboxEntities, indexes)
}
export default {
tags,
migrate,
rollback,
}

View file

@ -0,0 +1,11 @@
exports.tags = ['server-ce', 'server-pro']
exports.migrate = async client => {
const { db } = client
await db.users.updateMany(
{},
{ $set: { alphaProgram: false, betaProgram: false } }
)
}
exports.rollback = async () => {}

View file

@ -1,17 +0,0 @@
const tags = ['server-ce', 'server-pro']
const migrate = async client => {
const { db } = client
await db.users.updateMany(
{},
{ $set: { alphaProgram: false, betaProgram: false } }
)
}
const rollback = async () => {}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['saas']
exports.tags = ['saas']
const indexes = [
{
@ -15,18 +15,12 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.users, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
await Helpers.dropIndexesFromCollection(db.users, indexes)
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,6 +1,6 @@
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['server-ce', 'server-pro', 'saas']
exports.tags = ['server-ce', 'server-pro', 'saas']
const indexes = [
{
@ -13,22 +13,16 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.projectAuditLogEntries, indexes)
await Helpers.addIndexesToCollection(db.userAuditLogEntries, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
await Promise.all([
Helpers.dropIndexesFromCollection(db.userAuditLogEntries, indexes),
Helpers.dropIndexesFromCollection(db.projectAuditLogEntries, indexes),
])
}
export default {
tags,
migrate,
rollback,
}

View file

@ -0,0 +1,14 @@
const runScript = require('../scripts/migrate_audit_logs.js')
exports.tags = ['server-ce', 'server-pro', 'saas']
exports.migrate = async () => {
const options = {
letUserDoubleCheckInputsFor: 10,
writeConcurrency: 5,
dryRun: false,
}
await runScript(options)
}
exports.rollback = async () => {}

View file

@ -1,20 +0,0 @@
import runScript from '../scripts/migrate_audit_logs.js'
const tags = ['server-ce', 'server-pro', 'saas']
const migrate = async () => {
const options = {
letUserDoubleCheckInputsFor: 10,
writeConcurrency: 5,
dryRun: false,
}
await runScript(options)
}
const rollback = async () => {}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,6 +1,6 @@
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['server-ce', 'server-pro', 'saas']
exports.tags = ['server-ce', 'server-pro', 'saas']
const projectIndexes = [
{
@ -20,7 +20,7 @@ const userIndexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(
db.projectAuditLogEntries,
@ -29,7 +29,7 @@ const migrate = async client => {
await Helpers.addIndexesToCollection(db.userAuditLogEntries, userIndexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
await Promise.all([
Helpers.dropIndexesFromCollection(
@ -39,9 +39,3 @@ const rollback = async client => {
Helpers.dropIndexesFromCollection(db.userAuditLogEntries, userIndexes),
])
}
export default {
tags,
migrate,
rollback,
}

View file

@ -0,0 +1,9 @@
const runScript = require('../scripts/convert_archived_state')
exports.tags = ['server-ce', 'server-pro']
exports.migrate = async () => {
await runScript('FIRST,SECOND')
}
exports.rollback = async () => {}

View file

@ -1,15 +0,0 @@
import runScript from '../scripts/convert_archived_state.js'
const tags = ['server-ce', 'server-pro']
const migrate = async () => {
await runScript('FIRST,SECOND')
}
const rollback = async () => {}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['server-ce', 'server-pro', 'saas']
exports.tags = ['server-ce', 'server-pro', 'saas']
const indexes = [
{
@ -18,16 +18,10 @@ const indexes = [
},
]
const migrate = async ({ db }) => {
exports.migrate = async ({ db }) => {
await Helpers.addIndexesToCollection(db.projectHistoryChunks, indexes)
}
const rollback = async ({ db }) => {
exports.rollback = async ({ db }) => {
await Helpers.dropIndexesFromCollection(db.projectHistoryChunks, indexes)
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,10 +1,10 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['saas']
exports.tags = ['saas']
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
// 'recurly' -> 'recurlyStatus'
await db.subscriptions.updateMany(
@ -28,7 +28,7 @@ const migrate = async client => {
)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
// 'recurlyStatus' -> 'recurly'
await db.subscriptions.updateMany(
@ -51,9 +51,3 @@ const rollback = async client => {
{ $unset: { recurlyStatus: 1 } }
)
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,14 +1,13 @@
import BatchedUpdateScript from '../scripts/helpers/batchedUpdate.js'
const { batchedUpdate } = BatchedUpdateScript
const { batchedUpdate } = require('../scripts/helpers/batchedUpdate')
const tags = ['saas']
exports.tags = ['saas']
const batchedUpdateOptions = {
VERBOSE_LOGGING: 'true',
BATCH_SIZE: '1',
}
const migrate = async () => {
exports.migrate = async () => {
await batchedUpdate(
'users',
{ 'twoFactorAuthentication.secret': { $exists: true } },
@ -19,7 +18,7 @@ const migrate = async () => {
)
}
const rollback = async () => {
exports.rollback = async () => {
await batchedUpdate(
'users',
{ 'twoFactorAuthentication.secretEncrypted': { $exists: true } },
@ -29,9 +28,3 @@ const rollback = async () => {
batchedUpdateOptions
)
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,10 +1,10 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['saas']
exports.tags = ['saas']
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
db.subscriptions.updateMany(
{
@ -36,12 +36,6 @@ const migrate = async client => {
)
}
const rollback = async client => {
exports.rollback = async client => {
// There is no way back.
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,6 +1,6 @@
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['server-ce', 'server-pro', 'saas']
exports.tags = ['server-ce', 'server-pro', 'saas']
const indexes = [
{
@ -15,16 +15,10 @@ const indexes = [
},
]
const migrate = async ({ db }) => {
exports.migrate = async ({ db }) => {
await Helpers.addIndexesToCollection(db.projectHistoryChunks, indexes)
}
const rollback = async ({ db }) => {
exports.rollback = async ({ db }) => {
await Helpers.dropIndexesFromCollection(db.projectHistoryChunks, indexes)
}
export default {
tags,
migrate,
rollback,
}

View file

@ -0,0 +1,9 @@
const runScript = require('../scripts/back_fill_doc_rev')
exports.tags = ['server-ce', 'server-pro']
exports.migrate = async () => {
await runScript(false)
}
exports.rollback = async () => {}

View file

@ -1,15 +0,0 @@
import runScript from '../scripts/back_fill_doc_rev.js'
const tags = ['server-ce', 'server-pro']
const migrate = async () => {
await runScript(false)
}
const rollback = async () => {}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,6 +1,6 @@
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['server-ce', 'server-pro', 'saas']
exports.tags = ['server-ce', 'server-pro', 'saas']
const OLD_INDEX = {
key: { refreshToken: 1 },
@ -18,7 +18,7 @@ const TMP_INDEX = {
name: 'refreshToken_tmp',
}
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
// Create a temporary index so that the refresh tokens are not left unindexed
// while we drop the index and recreate it.
@ -32,7 +32,7 @@ const migrate = async client => {
await Helpers.dropIndexesFromCollection(db.oauthAccessTokens, [TMP_INDEX])
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
// Create a temporary index so that the refresh tokens are not left unindexed
// while we drop the index and recreate it.
@ -45,9 +45,3 @@ const rollback = async client => {
// Drop the temporary index
await Helpers.dropIndexesFromCollection(db.oauthAccessTokens, [TMP_INDEX])
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,6 +1,6 @@
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['server-ce', 'server-pro', 'saas']
exports.tags = ['server-ce', 'server-pro', 'saas']
const ACCESS_TOKENS_INDEX = {
name: 'expiresAt_1',
@ -16,7 +16,7 @@ const AUTHORIZATION_CODES_INDEX = {
expireAfterSeconds: 0,
}
const migrate = async ({ db }) => {
exports.migrate = async ({ db }) => {
await Helpers.addIndexesToCollection(db.oauthAccessTokens, [
ACCESS_TOKENS_INDEX,
])
@ -25,7 +25,7 @@ const migrate = async ({ db }) => {
])
}
const rollback = async ({ db }) => {
exports.rollback = async ({ db }) => {
await Helpers.dropIndexesFromCollection(db.oauthAccessTokens, [
ACCESS_TOKENS_INDEX,
])
@ -33,9 +33,3 @@ const rollback = async ({ db }) => {
AUTHORIZATION_CODES_INDEX,
])
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,6 +1,6 @@
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['server-ce', 'server-pro', 'saas']
exports.tags = ['server-ce', 'server-pro', 'saas']
const indexes = [
{
@ -10,18 +10,12 @@ const indexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.oauthAccessTokens, indexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
await Helpers.dropIndexesFromCollection(db.oauthAccessTokens, indexes)
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['server-ce', 'server-pro', 'saas']
exports.tags = ['server-ce', 'server-pro', 'saas']
const oldIndexes = [
{
@ -45,20 +45,14 @@ const newIndexes = [
},
]
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.projectHistoryChunks, newIndexes)
await Helpers.dropIndexesFromCollection(db.projectHistoryChunks, oldIndexes)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.projectHistoryChunks, oldIndexes)
await Helpers.dropIndexesFromCollection(db.projectHistoryChunks, newIndexes)
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,6 +1,6 @@
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['server-pro']
exports.tags = ['server-pro']
const OAUTH_APPLICATIONS_INDEX = {
key: { id: 1 },
@ -20,7 +20,7 @@ const OAUTH_AUTHORIZATION_CODES_INDEX = {
name: 'authorizationCode_1',
}
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.oauthApplications, [
OAUTH_APPLICATIONS_INDEX,
@ -33,7 +33,7 @@ const migrate = async client => {
])
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
await Helpers.dropIndexesFromCollection(db.oauthApplications, [
OAUTH_APPLICATIONS_INDEX,
@ -45,9 +45,3 @@ const rollback = async client => {
OAUTH_AUTHORIZATION_CODES_INDEX,
])
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,10 +1,9 @@
import util from 'util'
const { promisify } = util
const { promisify } = require('util')
const sleep = promisify(setTimeout)
const tags = ['server-ce', 'server-pro']
exports.tags = ['server-ce', 'server-pro']
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
const count = await db.projects.countDocuments({
'overleaf.history.display': { $ne: true },
@ -49,12 +48,6 @@ const migrate = async client => {
}
}
const rollback = async client => {
exports.rollback = async client => {
// Not applicable
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['saas']
exports.tags = ['saas']
const index = {
key: {
@ -11,18 +11,12 @@ const index = {
name: 'featuresUpdatedAt_1',
}
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.users, [index])
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
await Helpers.dropIndexesFromCollection(db.users, [index])
}
export default {
tags,
migrate,
rollback,
}

View file

@ -0,0 +1,11 @@
exports.tags = ['server-ce', 'server-pro']
exports.migrate = async () => {
// Run-time import as SaaS does not ship with the server-ce-scripts module
const runScript = require('../modules/server-ce-scripts/scripts/upgrade-user-features')
await runScript(false, {
gitBridge: 1,
})
}
exports.rollback = async () => {}

View file

@ -1,18 +0,0 @@
import runScript from '../modules/server-ce-scripts/scripts/upgrade-user-features.js'
const tags = ['server-ce', 'server-pro']
const migrate = async () => {
// Run-time import as SaaS does not ship with the server-ce-scripts module
await runScript(false, {
gitBridge: 1,
})
}
const rollback = async () => {}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,6 +1,6 @@
const tags = ['saas']
exports.tags = ['saas']
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await db.subscriptions.updateMany(
{ 'features.managedUsers': { $ne: true } },
@ -8,16 +8,10 @@ const migrate = async client => {
)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
await db.subscriptions.updateMany(
{ 'features.managedUsers': { $eq: null } },
{ $set: { 'features.managedUsers': false } }
)
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,6 +1,6 @@
import Helpers from './lib/helpers.mjs'
const Helpers = require('./lib/helpers')
const tags = ['saas']
exports.tags = ['saas']
const indexes = [
{
@ -9,16 +9,10 @@ const indexes = [
},
]
const migrate = async ({ db }) => {
exports.migrate = async ({ db }) => {
await Helpers.dropIndexesFromCollection(db.projects, indexes)
}
const rollback = async ({ db }) => {
exports.rollback = async ({ db }) => {
await Helpers.addIndexesToCollection(db.projects, indexes)
}
export default {
tags,
migrate,
rollback,
}

View file

@ -1,6 +1,6 @@
const tags = ['saas']
exports.tags = ['saas']
const migrate = async client => {
exports.migrate = async client => {
const { db } = client
await db.ssoConfigs.updateMany(
{ certificate: { $exists: true }, certificates: { $exists: false } },
@ -21,7 +21,7 @@ const migrate = async client => {
)
}
const rollback = async client => {
exports.rollback = async client => {
const { db } = client
await db.ssoConfigs.updateMany(
{ certificate: { $exists: false }, certificates: { $exists: true } },
@ -33,9 +33,3 @@ const rollback = async client => {
]
)
}
export default {
tags,
migrate,
rollback,
}

Some files were not shown because too many files have changed in this diff Show more