20190912145020_create_projectHistoryMetaData_indexes.mjs 715 B

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