You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
659 B

  1. const path = require('path')
  2. const fs = require('fs-extra')
  3. const semver = require('semver')
  4. /* global WIKI */
  5. module.exports = {
  6. /**
  7. * Gets the migration names
  8. * @returns Promise<string[]>
  9. */
  10. async getMigrations() {
  11. const absoluteDir = path.join(WIKI.SERVERPATH, 'db/migrations')
  12. const migrationFiles = await fs.readdirAsync(absoluteDir)
  13. return migrationFiles.sort(semver.compare).map(m => ({
  14. file: m,
  15. directory: absoluteDir
  16. }))
  17. },
  18. getMigrationName(migration) {
  19. return migration.file;
  20. },
  21. getMigration(migration) {
  22. return require(path.join(WIKI.SERVERPATH, 'db/migrations', migration.file));
  23. }
  24. }