Files
overleaf-cep/tools/migrations/20260603120000_recreate_libraryReferences_search_indexes_without_collation.mjs
T
Eric Mc Sween 528e587038 Merge pull request #35377 from overleaf/em-change-library-mongo-cluster
Add auxiliary Mongo cluster support for library collections

GitOrigin-RevId: 1cfdbe4bbeb6c95f1158834ae60a4e34bef7bb87
2026-09-17 11:26:00 +00:00

46 lines
1.1 KiB
JavaScript

import Helpers from './lib/helpers.mjs'
const tags = ['saas', 'auxiliary']
const oldIndexes = [
{
key: { userId: 1, searchKey: 1 },
name: 'userId_1_searchKey_1',
collation: { locale: 'en', strength: 1 },
},
{
key: { userId: 1, 'fields.searchValue': 1, 'fields.name': 1 },
name: 'userId_1_fields.searchValue_1_fields.name_1',
collation: { locale: 'en', strength: 1 },
},
]
const newIndexes = [
{
key: { userId: 1, searchKey: 1 },
name: 'userId_1_searchKey_1',
},
{
key: { userId: 1, 'fields.searchValue': 1, 'fields.name': 1 },
name: 'userId_1_fields.searchValue_1_fields.name_1',
},
]
const migrate = async client => {
const { db } = client
await Helpers.dropIndexesFromCollection(db.libraryReferences, oldIndexes)
await Helpers.addIndexesToCollection(db.libraryReferences, newIndexes)
}
const rollback = async client => {
const { db } = client
await Helpers.dropIndexesFromCollection(db.libraryReferences, newIndexes)
await Helpers.addIndexesToCollection(db.libraryReferences, oldIndexes)
}
export default {
tags,
migrate,
rollback,
}