migrationsList.js 783 B

12345678910111213141516171819202122232425262728293031
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = migrationsList;
  6. /**
  7. * A simple helper to build a list of migrations that is suitable according to
  8. * Umzug's format.
  9. *
  10. * @param {Array} migrations A list of migration. Each one must contain 'up', 'down' and 'name'.
  11. * @param {Array} params A facultative list of params that will be given to the 'up' and 'down' functions.
  12. * @returns {Array} The migrations in Umzug's format
  13. */
  14. function migrationsList(migrations, params = []) {
  15. const tmp = migrations.map(({
  16. up,
  17. down,
  18. name
  19. }) => ({
  20. file: name,
  21. testFileName: function testFileName(needle) {
  22. return this.file.indexOf(needle) === 0;
  23. },
  24. up,
  25. down
  26. }));
  27. tmp.params = params;
  28. return tmp;
  29. }