How to leverage models ?
BeauBouchard opened this issue · 1 comments
BeauBouchard commented
I am trying to leverage models from sequelize to do the migration
Conventionally I would do something like
'use strict';
module.exports = {
up: function (queryInterface, Sequelize) {
queryInterface.bulkInsert('users', [{
firstName: 'John',
lastName: 'Doe',
eyeColor: 'green'
}], {});
},
down: function (queryInterface, Sequelize) {
/*
Add reverting commands here.
Example:
return queryInterface.bulkDelete('users', null, {});
*/
}
};
I receive an error Unhandled rejection SequelizeDatabaseError: relation "users" does not exist
Is it because the models are not being utilized by the migrations.js?
JohnAdamsy commented
@BeauBouchard Not sure if this is related to your issue but it works for me: https://github.com/JohnAdamsy/sequelize-migration-hello/blob/master/migrations/migration-user/00_Initial.js#L5
But I had to add an instance of sequelize
as an argument in the migration.js
as here: https://github.com/JohnAdamsy/sequelize-migration-hello/blob/master/migrate.js#L16