20190912145004_create_docHistoryIndex_indexes.mjs 749 B

1234567891011121314151617181920212223242526272829303132333435
  1. import Helpers from './lib/helpers.mjs'
  2. import { getCollectionInternal } from './lib/mongodb.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. const migrate = async () => {
  13. const docHistoryIndex = await getCollectionInternal('docHistoryIndex')
  14. await Helpers.addIndexesToCollection(docHistoryIndex, indexes)
  15. }
  16. const rollback = async () => {
  17. const docHistoryIndex = await getCollectionInternal('docHistoryIndex')
  18. try {
  19. await Helpers.dropIndexesFromCollection(docHistoryIndex, indexes)
  20. } catch (err) {
  21. console.error('Something went wrong rolling back the migrations', err)
  22. }
  23. }
  24. export default {
  25. tags,
  26. migrate,
  27. rollback,
  28. }