Skip to content

Commit

Permalink
feat(seed): adding seed support for sequelize and compiled both into …
Browse files Browse the repository at this point in the history
…a gulp task, also took out the
  • Loading branch information
lirantal committed Jan 4, 2017
1 parent 27b4941 commit ae3eaf3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
7 changes: 6 additions & 1 deletion server/config/lib/sequelize.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,17 @@ if (config.orm) {

orm.sync = function () {
// Sync makes sure the database tables are created if they don't exist
// and the `force` parameter will also drop the tables before re-creating them
return this.sequelize.sync({
force: (config.seedDB.reset || false)
});
};

orm.seed = function () {
// Sync makes sure the database tables are created if they don't exist
// and the `force` parameter will also drop the tables before re-creating them
return this.sequelize.sync({ force: true });
};

}

// Export this ORM module
Expand Down
13 changes: 13 additions & 0 deletions server/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,19 @@ gulp.task('seed:mongoose', function(done) {
});
});

gulp.task('seed:sequelize', function(done) {
const sequelize = require('./config/lib/sequelize');

sequelize.seed()
.then(function() {
done();
});
});

gulp.task('test:seed', function(done) {
runSequence('seed:mongoose', 'seed:sequelize', done);
});

gulp.task('test:integration', function(done) {
runSequence('env:test', 'server:bootstrap', 'ava:test:integration', done);
});
Expand Down

0 comments on commit ae3eaf3

Please sign in to comment.