Ruby on rails 错误:列";姓名“身份证”;无法自动强制转换为您可能需要指定的整型;使用名称“u id::integer”;
我在将应用程序部署到heroku时遇到了最困难的情况。当我尝试运行Ruby on rails 错误:列";姓名“身份证”;无法自动强制转换为您可能需要指定的整型;使用名称“u id::integer”;,ruby-on-rails,postgresql,rails-migrations,Ruby On Rails,Postgresql,Rails Migrations,我在将应用程序部署到heroku时遇到了最困难的情况。当我尝试运行RAILS\u ENV=production bundle exec rake db:migrate时,我最终得到一个错误 PG::DatatypeMismatch: ERROR: column "downtown_id" cannot be cast automatically to type integer HINT: You might need to specify "USING downtown_id::intege
RAILS\u ENV=production bundle exec rake db:migrate时,我最终得到一个错误
PG::DatatypeMismatch: ERROR: column "downtown_id" cannot be cast automatically to type integer
HINT: You might need to specify "USING downtown_id::integer"
我试过的第一件事就是这个
def change
remove_column :properties, :downtown_id
add_column :properties, :downtown_id, :integer
end
不走运
然后我试了这个。(从中找到)
还是不走运(
在我的开发环境上运行这些迁移之后,在我可以尝试在RAILS\u ENV=production bundle exec rake db:migrate
上运行它们之前,我需要做什么
我不知道该怎么办,我所看到的一切都指向了我已经尝试过的东西
def change
change_column :properties, :downtown_id, 'integer USING CAST(downtown_id AS integer)'
end