Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 错误:列";姓名“身份证”;无法自动强制转换为您可能需要指定的整型;使用名称“u id::integer”;_Ruby On Rails_Postgresql_Rails Migrations - Fatal编程技术网

Ruby on rails 错误:列";姓名“身份证”;无法自动强制转换为您可能需要指定的整型;使用名称“u id::integer”;

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

我在将应用程序部署到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::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