I have been struggling with the db:seed:all
for over an hour now and slowly I am losing my mind about this.
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) {
// associations can be defined here
}
}
});
return Car;
};
this is in a migration and goes to the database using sequelize db:migrate
which works fine.
Next I wanted to insert - through a seed file - 2 cars.
So I ran the command sequelize seed:create --name insertCars
and added the 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 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
Has anyone got any experience with running these seeders? For your information here is my config 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.
sequelize db:migrate
? – EffieeffigyCars
vs. thecars
table postgres creates) – VasquesCars
– Muco