20230512100122_ensure_history_migration.mjs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import util from 'node:util'
  2. const { promisify } = util
  3. const sleep = promisify(setTimeout)
  4. const tags = ['server-ce', 'server-pro']
  5. const migrate = async client => {
  6. const { db } = client
  7. const totalProjects = await db.projects.estimatedDocumentCount()
  8. if (totalProjects === 0) return
  9. // Does not use an index.
  10. const count = await db.projects.countDocuments({
  11. 'overleaf.history.display': { $ne: true },
  12. })
  13. if (count > 0) {
  14. console.error(`
  15. -----------------------------------------------------------------------
  16. Full Project History migration not completed for ${count} projects.
  17. Starting with Server Pro/Community Edition version 4.0,
  18. all projects must use the full project history feature.
  19. Release 3.5 includes a migration process. Please go back to version
  20. 3.5 and run through the migration process:
  21. Overleaf Toolkit setups:
  22. toolkit$ echo "3.5.13" > config/version
  23. toolkit$ bin/up
  24. Legacy docker compose setups/Horizontal scaling setups:
  25. Update the image tag for "services -> sharelatex" to
  26. Server Pro: quay.io/sharelatex/sharelatex-pro:3.5.13.
  27. Community Edition: sharelatex/sharelatex:3.5.13
  28. Then use "docker compose up" to apply the changes.
  29. Documentation for the migration process:
  30. https://github.com/overleaf/overleaf/wiki/Full-Project-History-Migration
  31. Refusing to start up, exiting in 10s.
  32. -----------------------------------------------------------------------
  33. `)
  34. await sleep(10_000)
  35. throw new Error(
  36. `Found ${count} projects not migrated to Full Project History`
  37. )
  38. }
  39. }
  40. const rollback = async client => {
  41. // Not applicable
  42. }
  43. export default {
  44. tags,
  45. migrate,
  46. rollback,
  47. }