index.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. const _ = require('lodash')
  2. /* global WIKI */
  3. module.exports = {
  4. async migrate (knex) {
  5. const migrationsTableExists = await knex.schema.hasTable('migrations')
  6. if (!migrationsTableExists) {
  7. return
  8. }
  9. const migrations = await knex('migrations')
  10. if (_.some(migrations, m => m.name.indexOf('2.0.0') === 0)) {
  11. WIKI.logger.info('Found legacy 2.x installation of Wiki.js...')
  12. if (_.some(migrations, m => m.name.indexOf('2.5.128') === 0)) {
  13. // TODO: 2.x MIGRATIONS for 3.0
  14. WIKI.logger.error('Upgrading from 2.x is not yet supported. A future release will allow for upgrade from 2.x. Exiting...')
  15. process.exit(1)
  16. // -> Cleanup migration table
  17. await knex('migrations').truncate()
  18. // -> Advance to stable 3.0 migration state
  19. await knex('migrations').insert({
  20. name: '3.0.0.js',
  21. batch: 1,
  22. migration_time: knex.fn.now()
  23. })
  24. } else {
  25. console.error('CANNOT UPGRADE FROM OLDER UNSUPPORTED VERSION. UPGRADE TO THE LATEST 2.X VERSION FIRST! Exiting...')
  26. process.exit(1)
  27. }
  28. }
  29. }
  30. }