我是一名新手,对于nodejs不熟悉,同时我的英语也不好,请帮助我。我正在尝试使用knex在nodejs(express)中迁移我的数据库,而我使用的是Mysql数据库。我想要在表中重命名一个字段,但是当我尝试迁移我的数据库时,出现了一些问题,提示错误的默认值。
这是我正在尝试做的事情:
我的迁移
exports.up = function(knex) {
return knex.schema.table ('tbl_skills', function(table) {
table.renameColumn('preminum_price', 'premium_price')
})
};
Name | Datatype | length | Default |
id | INT | 20 | No default |
preminum_price | DOUBLE | 5,2 | No default |
insertdate | TIMESTAMP| | 0000-00-00 00:00:00 |
updatedate | TIMESTAMP| | 0000-00-00 00:00:00 |
当我尝试运行knex migrate:latest时,我得到了以下结果:
migration file "20191125105226_alter_tbl_skills.js" failed
migration failed with error: alter table `tbl_skills` change `preminum_price` `premium_price` double(5,2) NOT NULL - ER_INVALID_DEFAULT: Invalid default value for 'insertdate'
Error: ER_INVALID_DEFAULT: Invalid default value for 'insertdate'
我不知道如何设置默认值为insertdate。请帮忙。