20190912145015_create_oauthAccessTokens_indexes.mjs 737 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. accessToken: 1,
  9. },
  10. name: 'accessToken_1',
  11. },
  12. {
  13. unique: true,
  14. key: {
  15. refreshToken: 1,
  16. },
  17. name: 'refreshToken_1',
  18. },
  19. ]
  20. const migrate = async client => {
  21. const { db } = client
  22. await Helpers.addIndexesToCollection(db.oauthAccessTokens, indexes)
  23. }
  24. const rollback = async client => {
  25. const { db } = client
  26. try {
  27. await Helpers.dropIndexesFromCollection(db.oauthAccessTokens, indexes)
  28. } catch (err) {
  29. console.error('Something went wrong rolling back the migrations', err)
  30. }
  31. }
  32. export default {
  33. tags,
  34. migrate,
  35. rollback,
  36. }