【发布时间】:2015-09-16 09:00:08
【问题描述】:
我在 sequelize 中的迁移脚本没有创建时间戳列 createdAt、updatedAt
Error: SequelizeDatabaseError: ER_BAD_FIELD_ERROR: Unknown column 'createdAt' in 'field list'
我认为在迁移定义中将时间戳设置为 true 会自动创建列,我错了吗?
module.exports = {
up: function (queryInterface, Sequelize) {
return queryInterface.createTable('User', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
allowNull: false
},
uname: {
type: Sequelize.STRING(50)
}
},{
timestamps: true
})
...
【问题讨论】:
-
example in the docs 手动指定了时间戳,所以我猜你错了。
-
那么我想知道设置时间戳标志的目的是什么?
-
你在哪里看到的?模型定义和迁移系统似乎是相当独立的。我只在模型定义中看到了时间戳标志。
标签: sequelize.js