20250519101128_binary_files_migration_check.mjs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { setTimeout } from 'node:timers/promises'
  2. import { db } from '../app/src/infrastructure/mongodb.js'
  3. import Helpers from './lib/helpers.mjs'
  4. const tags = ['server-ce', 'server-pro']
  5. const migrate = async () => {
  6. const nActiveProjects = await db.projects.estimatedDocumentCount()
  7. const nDeletedProjects = await db.deletedProjects.estimatedDocumentCount()
  8. if (nActiveProjects === 0 && nDeletedProjects === 0) {
  9. // Empty database. Skip binary files migration check.
  10. return
  11. }
  12. try {
  13. await Helpers.assertDependency('20250519101128_binary_files_migration')
  14. } catch (err) {
  15. if (err instanceof Helpers.BadMigrationOrder) {
  16. console.warn('-'.repeat(79))
  17. console.warn(
  18. 'Please follow the binary files migration before upgrading to Server Pro/CE 6.0.'
  19. )
  20. console.warn()
  21. console.warn(
  22. ' Docs: https://docs.overleaf.com/on-premises/release-notes/release-notes-5.x.x/binary-files-migration'
  23. )
  24. console.warn()
  25. console.warn('-'.repeat(79))
  26. await setTimeout(5_000)
  27. process.exit(1)
  28. }
  29. throw err
  30. }
  31. }
  32. const rollback = async () => {}
  33. export default {
  34. tags,
  35. migrate,
  36. rollback,
  37. }