20230217205311_fix_deleted_history_chunks_index.mjs 805 B

123456789101112131415161718192021222324252627282930
  1. import Helpers from './lib/helpers.mjs'
  2. const tags = ['server-ce', 'server-pro', 'saas']
  3. const indexes = [
  4. {
  5. // The { state: -1 } sort order works around a restriction of Mongo 4.4
  6. // where it doesn't allow multiple indexes with the same keys and different
  7. // options. The restriction has been lifted in Mongo 5.0
  8. //
  9. // See https://www.mongodb.com/docs/manual/core/index-partial/#restrictions
  10. key: { state: -1 },
  11. name: 'state_pending',
  12. partialFilterExpression: { state: 'pending' },
  13. },
  14. ]
  15. const migrate = async ({ db }) => {
  16. await Helpers.addIndexesToCollection(db.projectHistoryChunks, indexes)
  17. }
  18. const rollback = async ({ db }) => {
  19. await Helpers.dropIndexesFromCollection(db.projectHistoryChunks, indexes)
  20. }
  21. export default {
  22. tags,
  23. migrate,
  24. rollback,
  25. }