20250912102601_add_timestamp_to_projectAuditLogEntries_index.mjs 769 B

123456789101112131415161718192021222324252627282930313233343536
  1. import Helpers from './lib/helpers.mjs'
  2. const oldIndex = {
  3. key: {
  4. projectId: 1,
  5. },
  6. name: 'project_id_1',
  7. }
  8. const newIndex = {
  9. key: {
  10. projectId: 1,
  11. timestamp: -1,
  12. },
  13. name: 'projectId_1_timestamp_-1',
  14. }
  15. const tags = ['server-ce', 'server-pro', 'saas']
  16. const migrate = async client => {
  17. const { db } = client
  18. await Helpers.addIndexesToCollection(db.projectAuditLogEntries, [newIndex])
  19. await Helpers.dropIndexesFromCollection(db.projectAuditLogEntries, [oldIndex])
  20. }
  21. const rollback = async client => {
  22. const { db } = client
  23. await Helpers.addIndexesToCollection(db.projectAuditLogEntries, [oldIndex])
  24. await Helpers.dropIndexesFromCollection(db.projectAuditLogEntries, [newIndex])
  25. }
  26. export default {
  27. tags,
  28. migrate,
  29. rollback,
  30. }