overleaf/services/web/migrations/20220913105500_create_auditLog_indexes.mjs
Liangjun Song 492fe24a75 Merge pull request #20480 from overleaf/ls-convert-migration-scripts-to-esm
Convert migration scripts to ESM

GitOrigin-RevId: 46f04a1837ebb8244b1156af2d58162d024b6b2d
2024-10-14 10:56:57 +00:00

34 lines
758 B
JavaScript

import Helpers from './lib/helpers.mjs'
const tags = ['server-ce', 'server-pro', 'saas']
const indexes = [
{
// expire after 2.5 years
expireAfterSeconds: 60 * 60 * 24 * 365 * 2.5,
key: {
timestamp: 1,
},
name: 'timestamp_1',
},
]
const migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.projectAuditLogEntries, indexes)
await Helpers.addIndexesToCollection(db.userAuditLogEntries, indexes)
}
const rollback = async client => {
const { db } = client
await Promise.all([
Helpers.dropIndexesFromCollection(db.userAuditLogEntries, indexes),
Helpers.dropIndexesFromCollection(db.projectAuditLogEntries, indexes),
])
}
export default {
tags,
migrate,
rollback,
}