I have a languages tabel in mysql db where I have an Id that is autoincremented:
CREATE TABLE `languages` (
`Id` int(11) NOT NULL AUTO_INCREMENT,
`Language` varchar(45) NOT NULL,
PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
When I run my sequelize-auto command:
sequelize-auto -h 127.0.0.1 -d DBNAME -u root -x PASSWORD -p 3306 --dialect mysql -c MYPATH\json/sequelize-auto-settings.json -o MODELSPATH\src\assets\models
I get the following modeL:
/* jshint indent: 1 */
module.exports = function(sequelize, DataTypes) {
return sequelize.define('languages', {
Id: {
type: DataTypes.INTEGER(11),
allowNull: false,
primaryKey: true,
field: 'Id'
},
Language: {
type: DataTypes.STRING(45),
allowNull: false,
field: 'Language'
}
}, {
tableName: 'languages'
});
};
Why am I missing the autoincrment : true
on the Id field ?
I can add it manually but it defeates the purpose of using sequelize -auto
This took some time and I can honstly say I still dont know what the issue was.
I solved it by installing sequelize-auto v3 and then it worked as intended.