20250728103841_group_audit_log_expire_index.mjs 583 B

1234567891011121314151617181920212223242526272829303132
  1. import Helpers from './lib/helpers.mjs'
  2. const tags = ['saas']
  3. const indexes = [
  4. {
  5. // expire after 2.5 years
  6. expireAfterSeconds: 60 * 60 * 24 * 365 * 2.5,
  7. key: {
  8. timestamp: 1,
  9. },
  10. name: 'timestamp_1',
  11. },
  12. ]
  13. const migrate = async client => {
  14. const { db } = client
  15. await Helpers.addIndexesToCollection(db.groupAuditLogEntries, indexes)
  16. }
  17. const rollback = async client => {
  18. const { db } = client
  19. await Promise.all([
  20. Helpers.dropIndexesFromCollection(db.groupAuditLogEntries, indexes),
  21. ])
  22. }
  23. export default {
  24. tags,
  25. migrate,
  26. rollback,
  27. }