Friday 25 October 2019

Sequelize unknown column in field list

Any help would be appreciated! I am still very new to Sequelize.I have recreated my MySQL Schema with sequelize migration and am getting this error... Anybody have any ideas? I thought it was a phantom column that I defined somewhere, but I looked pretty in-depth at my code and can't find it anywhere. (did a find within VScode on each file of my repository)​https://i.redd.it/stlyygw9xou31.pngI do not have a column called UserPermId in my database and it will work if I add that column manually with MySQL workbench. I don't want that field! :DHere is a look at my model and migration:Model:'use strict'; module.exports = (sequelize, DataTypes) => { const UsersTable = sequelize.define('Users', { fn: { type: DataTypes.STRING(10), allowNull: false }, ln: { type: DataTypes.STRING(10), allowNull: false }, username: { type: DataTypes.STRING(20), allowNull: false, unique: true, }, password: { type: DataTypes.STRING(200), allowNull: false }, permgroup: { type: DataTypes.INTEGER(2) } }, { tableName: 'Users', freezeTableName: true }); UsersTable.associate = function(models) { // associations can be defined here UsersTable.hasMany(models.WorkOrders); UsersTable.hasMany(models.CartDrafts); UsersTable.belongsTo(models.UserPerms); }; return UsersTable; }; Migration:'use strict'; module.exports = { up: (queryInterface, Sequelize) => { return queryInterface.createTable('Users', { id: { allowNull: false, autoIncrement: true, primaryKey: true, type: Sequelize.INTEGER }, fn: { type: Sequelize.STRING(10), allowNull: false }, ln: { type: Sequelize.STRING(10), allowNull: false }, username: { type: Sequelize.STRING(20), allowNull: false, unique: true, }, password: { type: Sequelize.STRING(200), allowNull: false }, permgroup: { // todo type: Sequelize.INTEGER(2), references: { model: 'UserPerms', key: 'id' }, onUpdate: 'cascade', onDelete: 'cascade' }, createdAt: { allowNull: false, type: Sequelize.DATE }, updatedAt: { allowNull: false, type: Sequelize.DATE } }); }, down: (queryInterface, Sequelize) => { return queryInterface.dropTable('Users'); } }; The Database shows the correct fields and even the foreign key:​https://i.redd.it/j1oawwvdyou31.png

Submitted October 25, 2019 at 02:44PM by Aberbob

No comments:

Post a Comment