控制台上执行下面的命令
rails g migration addColumnToBlackIps send_time:datetime
会生成文件db/migrate/20210529131328_add_column_to_black_ips.rb
class AddColumnToBlackIps < ActiveRecord::Migration[5.0]
def change
add_column :black_ips, :send_time, :datetime
end
end
执行迁移
rake db:migrate
执行结果
CREATE TABLE `black_ips` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ip` varchar(255) DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`send_time` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `index_black_ips_on_ip` (`ip`)
) ENGINE=InnoDB AUTO_INCREMENT=6115 DEFAULT CHARSET=utf8;