index.js 1.1 KB

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