mirror of
https://github.com/wassname/HackFlowy.git
synced 2026-06-27 16:00:04 +08:00
Made db:seed fail gracefully
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
var config = require('config'),
|
||||
sequelize = require("sequelize"),
|
||||
orm = require('../../orm').configure(config.get('database')),
|
||||
Tasks = require('../../db/models/task').instance(orm),
|
||||
demoData = require('../../public/javascripts/data/demo.json');
|
||||
|
||||
Tasks.destroy({where: {}}).then(function() {
|
||||
Tasks.bulkCreate(demoData);
|
||||
// Create tables if they dont exist
|
||||
Tasks.sync().then(function(){
|
||||
// fill demo data if it doesn't exist
|
||||
for (var i = 0; i < demoData.length; i++) {
|
||||
Tasks.findOrCreate({where: demoData[i]});
|
||||
}
|
||||
});
|
||||
|
||||
orm.sync();
|
||||
|
||||
Reference in New Issue
Block a user