I’ve been struggling with db:seed:all for more than an hour and am slowly losing my mind about it.
I have a simple model:
'use strict'; module.exports = function (sequelize, DataTypes) { var Car = sequelize.define('Cars', { name: DataTypes.STRING, type: DataTypes.INTEGER, models: DataTypes.INTEGER }, { classMethods: { associate: function (models) {
it is in the process of migration and goes to the database using sequelize db:migrate , which works fine.
Then I wanted to insert - through the seed file - 2 machines. So I sequelize seed:create --name insertCars and added bulkInsert :
'use strict'; module.exports = { up: function (queryInterface, Sequelize) { return queryInterface.bulkInsert( 'Cars', [ { name: "Auris", type: 1, models: 500, createdAt: Date.now(), updatedAt: Date.now() }, { name: "Yaris", type: 1, models: 500, createdAt: Date.now(), updatedAt: Date.now() } ] ); }, down: function (queryInterface, Sequelize) { } };
Now when I run sequelize db:seed:all , I get the following error:
Loaded configuration file "config\config.json". Using environment "development". == 20160510132128-insertCars: migrating ======= Seed file failed with error: Cannot read property 'name' of undefined
Does anyone have experience with these seeders? For your information, here is my configuration file:
{ "development": { "username": "mydbdude", "password": "mydbdude", "database": "Cars", "host": "127.0.0.1", "dialect": "mssql", "development": { "autoMigrateOldSchema": true } }, ....other configs }
EDIT: output from db: migrate
Sequelize [Node: 5.9.1, CLI: 2.4.0, ORM: 3.23.0] Loaded configuration file "config\config.json". Using environment "development". No migrations were executed, database schema was already up to date.