Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 332 Vote(s) - 3.52 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sequelize migration error: Cannot read property 'length' of undefined

#1
This is the tutorial I followed:

[To see links please register here]


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');
}
};


Reply

#2
Problem was relying on NUMBER DataType. Which was not found in the list of DataTypes of Sequelize (

[To see links please register here]

)

Change the following:

salary: {
type: Sequelize.NUMBER
}

to:

salary: {
type: Sequelize.DECIMAL(10, 2)
}


Also remember to update DataType the model related.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through