mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 13:13:45 +01:00
Add migration for libraryReferences trashedAt indexes
GitOrigin-RevId: 4a850c11560df3ae3053fbc66048b083e750b8d3
This commit is contained in:
committed by
Copybot
parent
e814176bba
commit
a71c8c24d9
@@ -0,0 +1,36 @@
|
||||
import Helpers from './lib/helpers.mjs'
|
||||
|
||||
const tags = ['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
|
||||
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,
|
||||
}
|
||||
Reference in New Issue
Block a user