heroku迁移默默地失败 [英] heroku migrations silently failing
问题描述
我有一个使用postgres 9.3的rails应用程序设置。我可以运行迁移,在本地运行我的服务器,并在本地获得正在运行的应用程序。
我将代码推到了heroku,并且一度运行。现在,当我运行heroku控制台时,它显示我的数据库完全是空的,我无法弄清楚如何重新创建它。
我使用v 0.17.1的pg宝石。
以下是我采取的步骤。
<1>创建了我的database.yml
开发:
适配器:postgresql
编码:unicode
数据库:fr_development
池:5
用户名:user
密码:密码
test:
适配器:postgresql
编码:unicode
数据库:fr_test
池:5
用户名:用户
密码:密码
制作:
网址:<%= ENV ['DATABASE_URL']%>
<1.5>设置我的heroku帐户并安装了papertrail
2)确保我的schema.rb和所有的迁移都在源代码控制之下。
3)运行git push heroku master
4)运行heroku run db:drop db:setup --app app或者在某个时候heroku pg:reset DATABASE_URL
5)运行heroku运行rake db:migrate --app应用程序
$ b $ 6 6)运行heroku restart --app应用程序
基本上不管我运行什么,所有我在papertrail中都是:
11月09日11:19: 50 app heroku / api:使用命令`bundle exec rake db:drop db:create db:migrate RAILS_ENV = production`通过email@gmail.com启动进程
Nov 09 11:19:53 app heroku / run.3003 :等待客户端
Nov 09 11:19:53 app heroku / run.3003:用命令`bundle exec rake db:drop db:create db:migrate RAILS_ENV = production`启动进程
Nov 09 11: 19:53 app heroku / run.3003:状态从开始变为向上
Nov 09 11:19:54 app heroku / run.3003:进程已退出,状态为0
2009年11月11日19时19分54秒app heroku / run.3003:状态从最高改为完成
然后,如果我打我的服务器,我会得到一个错误,指出我的一个关系不存在。
如果我heroku运行控制台并尝试运行我的任何表格,它会说它们不存在。
没有关于,并且很难找到资源来了解是否适合bin目录的配置。我还没碰过
我的bin / bundle完全是空的
pre $ $ $ $ $ #!bin / rails
begin
load File.expand_path(../ spring,__FILE__)
rescue LoadError
end
APP_PATH = File .expand_path('../../ config / application',__FILE__)
require_relative'../config/boot'
require'rails / commands'
。
#bin / rake
begin
load File.expand_path(../ spring,__FILE__)
rescue LoadError
end
require_relative'../config/boot'
require 'rake'
Rake.application.run
。
#bin / spring
除非已定义?(Spring)
需要rubygems
需要bundler
if match = Bundler.default_lockfile.read.match(/ ^ GEM $。*?^ spring \((。*?)\)$。*?^ $ / m)
ENV [ GEM_PATH] =([Bundler.bundle_path.to_s] + Gem.path).join(File :: PATH_SEPARATOR)
ENV [GEM_HO ME] =
Gem.paths = ENV
gemspring,match [1]
requirespring / binstub
end
结束
如果我运行了heroku pg:info我得到了
HEROKU_POSTGRESQL_ONYX_URL(DATABASE_URL)
计划:Hobby-dev
状态:可用
连接:1/20
PG版本: 9.3.3
创建时间:2014-11-06 04:08 UTC
数据大小:6.5 MB
表格数量:0
行数:0/10000(合规)
Fork / Follow:不支持的
Rollback:不支持的
最后一件可能相关的事继续看到这个堆栈跟踪文件,虽然我不知道它是否只是当我重置应用程序时会发生什么:
[2014-11-10 03:39:58] FATAL SignalException:SIGTERM
2009年11月19日19:39:58 app app / web.1:/app/vendor/ruby-2.1.4/lib/ruby/2.1 .0 / webrick / server.rb:170:在`select'
2009年11月19日19:39:58 app app / web.1:/app/vendor/ruby-2.1.4/l ib / ruby / 2.1.0 / webrick / server.rb:170:在`block in start'中
Nov 09 19:39:58 app app / web.1:/app/vendor/ruby-2.1.4 /lib/ruby/2.1.0/webrick/server.rb:32:in`start'
Nov 09 19:39:58 app app / web.1:/app/vendor/ruby-2.1.4/ lib / ruby / 2.1.0 / webrick / server.rb:160:在`start'
09年9月19日19:39:58 app app / web.1:/app/vendor/bundle/ruby/2.1.0 /gems/rack-1.5.2/lib/rack/handler/webrick.rb:14:in`run'
Nov 09 19:39:58 app app / web.1:/ app / vendor / bundle / ruby / 2.1.0 / gems / rack-1.5.2 / lib / rack / server.rb:264:在`start'
09年11月19:39:58 app app / web.1:/ app / vendor /bundle/ruby/2.1.0/gems/railties-4.1.5/lib/rails/commands/server.rb:69:in`start'
我真的试图调试这个,但我没有想法。任何帮助将不胜感激。
其他注意:我在这之前第一次设置postgres。我一直在使用它来破坏和创建用户,破坏和创建表格,但是我将所有事情都恢复到了本地的功能状态。不知道这是否能以某种方式发挥作用。
只要确定,如果您还没有,首先运行:
heroku run rake db:migrate
如果这样做不起作用:
heroku pg:reset
紧接着heroku运行rake db:再次迁移。
$ b $顺便说一下,我不认为Heroku允许您放弃或创建。因此,他们已经实现了pg:reset。
我发现了提及删除和创建权限以及使用pg的devcenter文档:reset here:
Note: this is my first time configuring a rails application, deploying a rails app and setting up a database. I very well might be doing something obviously stupid.
I have a working rails application setup with postgres 9.3. I can run migrations, run my server locally and get a running application locally.
I pushed my code up to heroku and at one point it ran. Now when I run the heroku console it shows that my database is totally empty and I cannot figure out how to recreate it.
I am using v 0.17.1 of the pg gem.
Here are the steps I have taken.
1) Created my database.yml
development:
adapter: postgresql
encoding: unicode
database: fr_development
pool: 5
username: user
password: password
test:
adapter: postgresql
encoding: unicode
database: fr_test
pool: 5
username: user
password: password
production:
url: <%= ENV['DATABASE_URL'] %>
1.5) setup my heroku account and installed papertrail
2) Made sure my schema.rb and all migrations are under source control.
3) ran "git push heroku master"
4) ran "heroku run db:drop db:setup --app app" or alternately sometime "heroku pg:reset DATABASE_URL"
5) ran "heroku run rake db:migrate --app app"
6) ran "heroku restart --app app"
Basically no matter what I run, all i get in papertrail is:
Nov 09 11:19:50 app heroku/api: Starting process with command `bundle exec rake db:drop db:create db:migrate RAILS_ENV=production` by email@gmail.com
Nov 09 11:19:53 app heroku/run.3003: Awaiting client
Nov 09 11:19:53 app heroku/run.3003: Starting process with command `bundle exec rake db:drop db:create db:migrate RAILS_ENV=production`
Nov 09 11:19:53 app heroku/run.3003: State changed from starting to up
Nov 09 11:19:54 app heroku/run.3003: Process exited with status 0
Nov 09 11:19:54 app heroku/run.3003: State changed from up to complete
And then if I hit my server Ill get an error that one of my relations doesnt exist.
If I "heroku run console" and try to run any of my tables it will say they dont exist.
One thing I no nothing about and am having a hard time finding resources to learn about is proper configurations for bin directory stuff. I have not touched
my bin/bundle is totally empty
#!bin/rails
begin
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'
.
#bin/rake
begin
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
require_relative '../config/boot'
require 'rake'
Rake.application.run
.
#bin/spring
unless defined?(Spring)
require "rubygems"
require "bundler"
if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ spring \((.*?)\)$.*?^$/m)
ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR)
ENV["GEM_HOME"] = ""
Gem.paths = ENV
gem "spring", match[1]
require "spring/binstub"
end
end
if I run heroku pg:info i get
HEROKU_POSTGRESQL_ONYX_URL (DATABASE_URL)
Plan: Hobby-dev
Status: Available
Connections: 1/20
PG Version: 9.3.3
Created: 2014-11-06 04:08 UTC
Data Size: 6.5 MB
Tables: 0
Rows: 0/10000 (In compliance)
Fork/Follow: Unsupported
Rollback: Unsupported
One last thing that may be relevant I keep seeing this stack trace in paper trail although I'm not sure if it is just what happens when I reset the app:
[2014-11-10 03:39:58] FATAL SignalException: SIGTERM
Nov 09 19:39:58 app app/web.1: /app/vendor/ruby-2.1.4/lib/ruby/2.1.0/webrick/server.rb:170:in `select'
Nov 09 19:39:58 app app/web.1: /app/vendor/ruby-2.1.4/lib/ruby/2.1.0/webrick/server.rb:170:in `block in start'
Nov 09 19:39:58 app app/web.1: /app/vendor/ruby-2.1.4/lib/ruby/2.1.0/webrick/server.rb:32:in `start'
Nov 09 19:39:58 app app/web.1: /app/vendor/ruby-2.1.4/lib/ruby/2.1.0/webrick/server.rb:160:in `start'
Nov 09 19:39:58 app app/web.1: /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/handler/webrick.rb:14:in `run'
Nov 09 19:39:58 app app/web.1: /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/server.rb:264:in `start'
Nov 09 19:39:58 app app/web.1: /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.5/lib/rails/commands/server.rb:69:in `start'
I have really tried to debug this one but I am out of ideas. Any help would be greatly appreciated.
other note: I setup postgres for the first time right before this. I was mucking around with it alot destorying and creating users and destroying and creating tables but I got everything back to a functional state locally. Don't know if that could somehow play into this.
Just to make sure, if you haven't already, first run:
heroku run rake db:migrate
And if then if that doesn't work:
heroku pg:reset
Followed by the heroku run rake db:migrate again.
By the way, I don't think Heroku gives you permission to to drop or create. Thus they've implemented pg:reset.
I found the devcenter doc that mentions permissions for dropping and creating and on using pg:reset here: https://devcenter.heroku.com/articles/rake
这篇关于heroku迁移默默地失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!