20250828100935_drop_old_lastBackedUpVersion_index.mjs 891 B

123456789101112131415161718192021222324252627282930313233343536
  1. /* eslint-disable no-unused-vars */
  2. import Helpers from './lib/helpers.mjs'
  3. const tags = ['saas']
  4. const indexes = [
  5. {
  6. key: { 'overleaf.backup.lastBackedUpVersion': 1 },
  7. name: 'overleaf.backup.lastBackedUpVersion_1',
  8. partialFilterExpression: {
  9. 'overleaf.backup.lastBackedUpVersion': { $in: [null] },
  10. },
  11. },
  12. ]
  13. const migrate = async client => {
  14. const { db } = client
  15. // Ensure the optimisation migration has run first to create the new index
  16. await Helpers.assertDependency(
  17. '20250827155732_optimise_lastBackedUpVersion_index'
  18. )
  19. // Drop the old index from 20250307120446_create_project_lastBackedUpVersion_index
  20. await Helpers.dropIndexesFromCollection(db.projects, indexes)
  21. }
  22. const rollback = async client => {
  23. const { db } = client
  24. await Helpers.addIndexesToCollection(db.projects, indexes)
  25. }
  26. export default {
  27. tags,
  28. migrate,
  29. rollback,
  30. }