20190912145007_create_docSnapshots_indexes.mjs 729 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* eslint-disable no-unused-vars */
  2. import Helpers from './lib/helpers.mjs'
  3. const tags = ['server-ce', 'server-pro', 'saas']
  4. const indexes = [
  5. {
  6. key: {
  7. project_id: 1,
  8. },
  9. name: 'project_id_1',
  10. },
  11. {
  12. key: {
  13. ts: 1,
  14. },
  15. name: 'ts_1',
  16. expireAfterSeconds: 2592000,
  17. },
  18. ]
  19. const migrate = async client => {
  20. const { db } = client
  21. await Helpers.addIndexesToCollection(db.docSnapshots, indexes)
  22. }
  23. const rollback = async client => {
  24. const { db } = client
  25. try {
  26. await Helpers.dropIndexesFromCollection(db.docSnapshots, 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. }