This is the tutorial I followed: https://medium.com/@prajramesh93/getting-started-with-node-express-and-mysql-using-sequelize-ed1225afc3e0
This is node js project using express + mysql where I use and ORM Sequelize.
I get this error when trying to run sequelize db:migrate
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('Employees', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
name: {
type: Sequelize.STRING
},
designation: {
type: Sequelize.STRING
},
salary: {
type: Sequelize.NUMBER
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
},
companyId: {
type: Sequelize.NUMBER,
onDelete: 'CASCADE',
references: {
model: 'Companies',
key: 'id',
as: 'companyId',
}
}
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable('Employees');
}
};
Problem was relying on NUMBER DataType. Which was not found in the list of DataTypes of Sequelize ( https://sequelize.org/master/manual/model-basics.html#data-types )
Change the following:
salary: {
type: Sequelize.NUMBER
}
to:
salary: {
type: Sequelize.DECIMAL(10, 2)
}
Also remember to update DataType the model related.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With