Files
overleaf-cep/tools/migrations/20260722120000_create_libraryReferences_trashedAt_indexes.mjs
T
Eric Mc Sween c55411ee99 Merge pull request #36802 from overleaf/em-migrations-auxiliary-tags
[migrations] tag the auxiliary library migrations for saas

GitOrigin-RevId: cfe1169af24b36d6dcb352b4e0f79b250d74a1a0
2026-09-17 12:02:53 +00:00

37 lines
958 B
JavaScript

import Helpers from './lib/helpers.mjs'
const tags = ['saas', 'auxiliary']
// Two partial indexes (docs without trashedAt are not indexed) supporting the
// soft-delete (trash) feature
// - userId_1_trashedAt_1__id_1 serves the per-user trash listing/search,
// - trashedAt_1 serves the daily expiry cron's cross-user scan.
const newIndexes = [
{
key: { userId: 1, trashedAt: 1, _id: 1 },
name: 'userId_1_trashedAt_1__id_1',
partialFilterExpression: { trashedAt: { $exists: true } },
},
{
key: { trashedAt: 1 },
name: 'trashedAt_1',
partialFilterExpression: { trashedAt: { $exists: true } },
},
]
const migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.libraryReferences, newIndexes)
}
const rollback = async client => {
const { db } = client
await Helpers.dropIndexesFromCollection(db.libraryReferences, newIndexes)
}
export default {
tags,
migrate,
rollback,
}