20250331120946_add_email_to_teamInvites_index.mjs 689 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import Helpers from './lib/helpers.mjs'
  2. const indexes = [
  3. {
  4. key: {
  5. 'teamInvites.email': 1,
  6. },
  7. name: 'teamInvites.email_1',
  8. partialFilterExpression: {
  9. 'teamInvites.email': {
  10. $exists: true,
  11. },
  12. },
  13. },
  14. ]
  15. const tags = ['saas']
  16. const migrate = async client => {
  17. const { db } = client
  18. await Helpers.addIndexesToCollection(db.subscriptions, indexes)
  19. }
  20. const rollback = async client => {
  21. const { db } = client
  22. try {
  23. await Helpers.dropIndexesFromCollection(db.subscriptions, indexes)
  24. } catch (err) {
  25. console.error('Something went wrong rolling back the migrations', err)
  26. }
  27. }
  28. export default {
  29. tags,
  30. migrate,
  31. rollback,
  32. }