20190912145009_create_githubSyncEntityVersions_indexes.mjs 748 B

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