20190912145019_create_projectHistoryLabels_indexes.mjs 722 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. user_id: 1,
  14. },
  15. name: 'user_id_1',
  16. },
  17. ]
  18. const migrate = async client => {
  19. const { db } = client
  20. await Helpers.addIndexesToCollection(db.projectHistoryLabels, indexes)
  21. }
  22. const rollback = async client => {
  23. const { db } = client
  24. try {
  25. await Helpers.dropIndexesFromCollection(db.projectHistoryLabels, indexes)
  26. } catch (err) {
  27. console.error('Something went wrong rolling back the migrations', err)
  28. }
  29. }
  30. export default {
  31. tags,
  32. migrate,
  33. rollback,
  34. }