【发布时间】:2012-05-23 07:27:38
【问题描述】:
我似乎遇到了困难,在这里和其他论坛上进行了搜索,但一无所获。我正在运行 rails 3.2.3 和 ruby 1.9.3,并希望在 heroku 上部署我的应用程序。
我已经创建了 cedar,虽然我可以 git push heroku master 我得到一个完整的 500 服务器错误。
我怀疑是因为我的数据库不在那里。但是,我似乎无法到达那里。
我跑了:
heroku run rake db:create -> 这给出了一些关于弃用的警告,然后是dkhgclqccm already exists
所以它已经存在了?所以让我们迁移它:
heroku run rake db:migrate
然而这输出:
<deprecation errors>
rake aborted!
An error has occurred, this and all later migrations canceled:
PG::Error: ERROR: relation "hphotos" does not exist
: ALTER TABLE "hphotos" ADD COLUMN "description" character varying(255)
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
特定的迁移是:
class AddDescriptionToHphotos < ActiveRecord::Migration
def change
add_column :hphotos, :description, :string
end
end
对我来说似乎不错,不知道为什么给我这个错误:/
最后一件事,即使迁移成功,我的数据库也会是空的,并且我的seeds.rb 没有数据库所需的所有数据。所以我想推孔DB。
heroku db:push
! Taps Load Error: cannot load such file -- sqlite3
! You may need to install or update the taps gem to use db commands.
! On most systems this will be:
!
! sudo gem install taps
为什么会这样显示? 我安装了 'heroku' gem 和 'taps' gem,并在我的 gem 文件中得到了这个:
group :development, :test do
gem 'mysql2'
end
group :production do
gem 'pg'
end
另外,当我运行heroku run rake db:version 时,它显示:当前版本:20120508130957
这实际上是我当前版本的 5 次迁移,但我无法迁移它,正如我上面提到的错误所示......
提前致谢
【问题讨论】:
-
显然在创建表的迁移之前调用了此迁移。不知道那是怎么回事。解决方案是手动删除迁移,然后创建一个新的 stack cedar 应用程序。然后迁移,播种,一切都很好。
-
这正是我向您指出的内容“似乎尚未远程创建表,您正在尝试修改它。”不胜感激。
标签: ruby-on-rails database deployment heroku