20190912145003_create_deletedSubscriptions_indexes.mjs 757 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* eslint-disable no-unused-vars */
  2. import Helpers from './lib/helpers.mjs'
  3. const tags = ['saas']
  4. const indexes = [
  5. {
  6. unique: true,
  7. key: {
  8. 'subscription._id': 1,
  9. },
  10. name: 'subscription._id_1',
  11. },
  12. {
  13. key: {
  14. 'subscription.admin_id': 1,
  15. },
  16. name: 'subscription.admin_id_1',
  17. },
  18. ]
  19. const migrate = async client => {
  20. const { db } = client
  21. await Helpers.addIndexesToCollection(db.deletedSubscriptions, indexes)
  22. }
  23. const rollback = async client => {
  24. const { db } = client
  25. try {
  26. await Helpers.dropIndexesFromCollection(db.deletedSubscriptions, indexes)
  27. } catch (err) {
  28. console.error('Something went wrong rolling back the migrations', err)
  29. }
  30. }
  31. export default {
  32. tags,
  33. migrate,
  34. rollback,
  35. }