Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql Sequelize迁移因无法读取属性而失败';toString';未定义的_Mysql_Node.js_Sequelize.js - Fatal编程技术网

Mysql Sequelize迁移因无法读取属性而失败';toString';未定义的

Mysql Sequelize迁移因无法读取属性而失败';toString';未定义的,mysql,node.js,sequelize.js,Mysql,Node.js,Sequelize.js,尝试在Sequelize上运行迁移时,出现以下错误: == 20170904085107-kognitio-queue: migrating ======= TypeError: Cannot read property 'toString' of undefined at Object.attributeToSQL (/home/vagrant/insights-api/node_modules/sequelize/lib/dialects/mysql/query-generator.

尝试在Sequelize上运行迁移时,出现以下错误:

== 20170904085107-kognitio-queue: migrating =======
TypeError: Cannot read property 'toString' of undefined
    at Object.attributeToSQL (/home/vagrant/insights-api/node_modules/sequelize/lib/dialects/mysql/query-generator.js:240:34)
    at Object.attributesToSQL (/home/vagrant/insights-api/node_modules/sequelize/lib/dialects/mysql/query-generator.js:306:45)
    at QueryInterface.createTable (/home/vagrant/insights-api/node_modules/sequelize/lib/query-interface.js:171:38)
    at Object.up (/home/vagrant/insights-api/lib/migrations/20170904085107-kognitio-queue.js:4:31)
    at constructor._exec (/home/vagrant/insights-api/node_modules/umzug/lib/migration.js:104:23)
    at constructor.up (/home/vagrant/insights-api/node_modules/umzug/lib/migration.js:69:17)
    at constructor.<anonymous> (/home/vagrant/insights-api/node_modules/umzug/index.js:124:28)
    at PassThroughHandlerContext.finallyHandler (/home/vagrant/insights-api/node_modules/bluebird/js/release/finally.js:57:23)
    at PassThroughHandlerContext.tryCatcher (/home/vagrant/insights-api/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/vagrant/insights-api/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/home/vagrant/insights-api/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/home/vagrant/insights-api/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/home/vagrant/insights-api/node_modules/bluebird/js/release/promise.js:693:18)
    at Promise._fulfill (/home/vagrant/insights-api/node_modules/bluebird/js/release/promise.js:638:18)
    at Promise._resolveCallback (/home/vagrant/insights-api/node_modules/bluebird/js/release/promise.js:432:57)
    at Promise._settlePromiseFromHandler (/home/vagrant/insights-api/node_modules/bluebird/js/release/promise.js:524:17)
我的模型文件是

module.exports = (sequelize, DataTypes) => {
    const Kognitio_Queue = sequelize.define('Kognitio_Queue', {
        queue_id: {
            type: DataTypes.INTEGER,
            allowNull: false,
            primaryKey: true,
        },
        queue_user: {
            type: DataTypes.STRING(20),
            allowNull: false
        },
        queue_query: {
            allowNull: false,
            type: DataTypes.LONG
        },
        queue_added: {
            allowNull: false,
            type: DataTypes.DATETIME
        },
        queue_executed: {
            allowNull: true,
            type: DataTypes.DATETIME
        },
        queue_save_results: {
            allowNull: false,
            type: DataTypes.BOOLEAN
        },
        queue_results_path: {
            allowNull: true,
            type: DataTypes.TEXT
        }
    }, {
        underscored: true,
        freezeTableName: true
    });
    return Kognitio_Queue;
};
我不知道是什么原因导致发生此错误,因为我已将这些文件与其他成功运行的迁移进行了对比,并且看不到它们之间的差异。我甚至清理了整个数据库并重新编译,但这是唯一一个失败的


提前感谢。

发现这是无法识别的数据类型。

将日期时间更改为日期,续集中没有名为日期时间的数据类型。DATE的工作原理与DATETIME相同,DATEONLY的工作原理与DATE类似
详细信息:

确保使用大写数据类型:


使用DATE而不是DATE或DATE

Uffff,sequelize中的错误捕获可以更详细地解释错误。在某些情况下,类型中的错误会丢失。在我的例子中:我想更新AllowFull属性,但是我没有更新类型。我希望它能解决你的疑问。谢谢!你救了我!
module.exports = (sequelize, DataTypes) => {
    const Kognitio_Queue = sequelize.define('Kognitio_Queue', {
        queue_id: {
            type: DataTypes.INTEGER,
            allowNull: false,
            primaryKey: true,
        },
        queue_user: {
            type: DataTypes.STRING(20),
            allowNull: false
        },
        queue_query: {
            allowNull: false,
            type: DataTypes.LONG
        },
        queue_added: {
            allowNull: false,
            type: DataTypes.DATETIME
        },
        queue_executed: {
            allowNull: true,
            type: DataTypes.DATETIME
        },
        queue_save_results: {
            allowNull: false,
            type: DataTypes.BOOLEAN
        },
        queue_results_path: {
            allowNull: true,
            type: DataTypes.TEXT
        }
    }, {
        underscored: true,
        freezeTableName: true
    });
    return Kognitio_Queue;
};