class ChangeColumnTypeToDevices < ActiveRecord::Migration [5.0]
def change
change_column :devices, :status, :integer
end
end
执行
rails db:migrate
报错:
Mysql2::Error: Incorrect datetime value: '0000-00-00 00:00:00' for column 'created_at' at row 1
......
G 了好长时间,确定是 MySQL 5.7 的空日期配置不接收 0000-00-00 00:00:00 这样的格式,解决办法:
用 root 登录到 MySQL,修改一下配置参数就 OK 了
>mysql -uroot -p devices
>SET GLOBAL sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
MARK!