diff --git a/lib/tasks/db.js b/lib/tasks/db.js index 6fbeb998..ec8a5cc1 100644 --- a/lib/tasks/db.js +++ b/lib/tasks/db.js @@ -113,7 +113,9 @@ module.exports = { task: function () { return getMigrator('seeder').then(function (migrator) { - return migrator.pending() + return ( + helpers.umzug.getStorage('seeder') === 'none' ? migrator.pending() : migrator.executed() + ) .then(function (seeders) { if (seeders.length === 0) { console.log('No seeders found.'); diff --git a/test/db/seed/undo/all.test.js b/test/db/seed/undo/all.test.js index 7e7a2d5c..a5e7df60 100644 --- a/test/db/seed/undo/all.test.js +++ b/test/db/seed/undo/all.test.js @@ -4,12 +4,14 @@ var expect = require('expect.js'); var Support = require(__dirname + '/../../../support'); var helpers = require(__dirname + '/../../../support/helpers'); var gulp = require('gulp'); +var _ = require('lodash'); ([ 'db:seed:undo:all' ]).forEach(function (flag) { var prepare = function (callback, options) { - var _flag = options.flag || flag; + var _flag = options.flag || flag; + var config = _.assign({}, helpers.getTestConfig(), options.config || {}); var pipeline = gulp .src(Support.resolveSupportPath('tmp')) @@ -22,7 +24,7 @@ var gulp = require('gulp'); .pipe(helpers.copySeeder('seedPerson2.js')); } - pipeline.pipe(helpers.overwriteFile(JSON.stringify(helpers.getTestConfig()), + pipeline.pipe(helpers.overwriteFile(JSON.stringify(config), 'config/config.json')) .pipe(helpers.runCli('db:migrate')) .pipe(helpers.runCli(_flag, { pipeStdout: true })) @@ -59,5 +61,31 @@ var gulp = require('gulp'); }); }, {flag: 'db:seed:all', copySeeds: true}); }); + + it('is correctly undoing all seeders when storage is none', function (done) { + var self = this; + + prepare(function () { + helpers.countTable(self.sequelize, 'Person', function (res) { + expect(res).to.have.length(1); + expect(res[0].count).to.eql(2); + + gulp + .src(Support.resolveSupportPath('tmp')) + .pipe(helpers.runCli(flag, { pipeStdout: true })) + .pipe(helpers.teardown(function () { + helpers.countTable(self.sequelize, 'Person', function (res) { + expect(res).to.have.length(1); + expect(res[0].count).to.eql(0); + done(); + }); + })); + }); + }, { + flag: 'db:seed:all', + copySeeds: true, + config: { seederStorage: 'none' } + }); + }); }); });