2012-02-03 4 views
-1

최근에 확인 가능한 모듈을 내 레일 앱에 추가했습니다. 내 응용 프로그램은 dev에서 잘 실행됩니다. 그러나, 나는 그것을 영웅에게 밀어 넣을 때, "유감 스럽지만 뭔가 잘못 됐어."라고 말합니다. 다음은 내 히로쿠 로그입니다.heroku rails app 데이터베이스 이전 문제

Rendered devise/confirmations/new.html.erb within layouts/application (2.7ms) 
2012-02-03T01:55:07+00:00 app[web.1]: Rendered devise/shared/_links.erb (0.5ms) 
2012-02-03T01:55:07+00:00 app[web.1]: cache: [GET /users/confirmation/new] miss 
2012-02-03T01:55:07+00:00 app[web.1]: Completed 200 OK in 19ms (Views: 16.9ms | ActiveRecord: 0.0ms) 
2012-02-03T01:55:07+00:00 heroku[router]: GET personaldiary.herokuapp.com/users/confirmation/new dyno=web.1 queue=0 wait=0ms service=42ms status=200 bytes=1540 
2012-02-03T01:55:11+00:00 app[web.1]: 
2012-02-03T01:55:11+00:00 app[web.1]: 
2012-02-03T01:55:11+00:00 app[web.1]: Started POST "https://stackoverflow.com/users/confirmation" for 50.131.164.83 at 2012-02-03 01:55:11 +0000 
2012-02-03T01:55:11+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "authenticity_token"=>"iVVTpWgIrBTR8b9k07lr2tYDFQfAYD0R8JmGVkmfzl4=", "user"=>{"email"=>"[email protected]"}, "commit"=>"Resend confirmation instructions"} 
2012-02-03T01:55:11+00:00 app[web.1]: Processing by Devise::ConfirmationsController#create as HTML 
2012-02-03T01:55:11+00:00 app[web.1]: Completed 500 Internal Server Error in 4ms 
2012-02-03T01:55:11+00:00 app[web.1]: 
2012-02-03T01:55:11+00:00 app[web.1]: NameError (undefined local variable or method `confirmed_at' for #<User:0x000000023254e0>): 
2012-02-03T01:55:11+00:00 app[web.1]: 
2012-02-03T01:55:11+00:00 app[web.1]: cache: [POST /users/confirmation] invalidate, pass 
2012-02-03T01:55:11+00:00 app[web.1]: 

데이터베이스에는 "confirmed_at"열이 없습니다. 다음과 같이 내 마이그레이션 파일은 다음과 같습니다

class AddConfirmableToDeviseV1 < ActiveRecord::Migration 
    def up 
    add_column :users, :confirmation_token, :string 
    add_column :users, :confirmed_at, :datetime 
    add_column :users, :confirmation_sent_at , :datetime 

    add_index :users, :confirmation_token, :unique => true 
    end 

    def down 
    remove_index :users, :confirmation_token 

    remove_column :users, :confirmation_sent_at 
    remove_column :users, :confirmed_at 
    remove_column :users, :confirmation_token 
    end 
end 

내 생산은 Heroku가에서 호스팅 :

는 그래서 그것은 나에게 아무런 출력을 포기하지
heroku run rake db:migrate 

을 달렸다.

은 그 때 나는 그것은

** Invoke db:migrate (first_time) 
** Invoke environment (first_time) 
** Execute environment 
** Invoke db:load_config (first_time) 
** Invoke rails_env (first_time) 
** Execute rails_env 
** Execute db:load_config 
** Execute db:migrate 
** Invoke db:schema:dump (first_time) 
** Invoke environment 
** Invoke db:load_config 
** Execute db:schema:dump 
,691,363 다음 나에게 또한

== AddConfirmableToDeviseV1: reverting ======================================= 
-- remove_index(:users, :confirmation_token) 
rake aborted! 
An error has occurred, this and all later migrations canceled: 

Index name 'index_users_on_confirmation_token' on table 'users' does not exist 

Tasks: TOP => db:rollback 

,

heroku run rake db:migrate --trace 

나에게 제공했다

heroku run rake db:rollback 

를 실행210

모든 아이디어이 문제를 해결하는 방법?

+0

db : migrate를 --trace와 함께 실행할 수 있으며 출력이 있는지 확인할 수 있습니까? –

+0

** DB를 호출 (first_time) 이전 를 ** 환경 실행 ** 환경 (first_time) 를 호출 ** DB를 호출 : load_config (first_time) 를 ** RAILS_ENV 실행 ** RAILS_ENV (first_time) 를 호출 ** 실행 DB : load_config ** DB를 실행합니다 를 마이그레이션 ** DB 호출 : 스키마를 : 스키마 : load_config ** DB를 실행합니다 을 (first_time) 덤프 ** 환경 를 호출 ** DB를 호출 – riship89

+0

는 여러 응용 프로그램의 설정을 가지고 있나요 덤프 Heroku에서? –

답변

0

문제를

(분명히 생산 Heroku가 환경에 대한 마이그레이션을 실행하는 올바른 방법입니다 참고 : "마이그레이션에게 Heroku는 갈퀴 DB를 실행"- -하지 않는 Heroku가 특정 대답이 일반적인 의견이다).

마이그레이션 파일을 삭제했습니다. 마이그레이션 변경 방법에 개발자 헬퍼가 포함 된 새 마이그레이션 파일을 추가했습니다.

class AddConfirmableToDevise < ActiveRecord::Migration 
    def change 
     change_table(:users) do |t| 
      t.confirmable 
     end 
     add_index :users, :confirmation_token, :unique => true 
    end 
end 

heroku run rake db:migrate 

다시 마이그레이션을 실행하고 워 ... 일했다. 나는 이것이 어떻게 의미가 있는지 모르지만, 그것이 효과가있어 기쁘다. 의견을 남겨주세요, 나는 설명을 읽고 싶어합니다.

어쨌든 모두에게 감사드립니다.

+0

으로 바꿉니다. 그러나 확실하지는 않지만 heroku는 위아래 방법을 지원하지 않습니다. 아무도 이것을 확인하지 못했습니다. – riship89

1

마이그레이션을 프로덕션 데이터베이스에 대해 실행해야합니다.

RAILS_ENV=production rake db:migrate 

이는 로컬 환경에서 프로덕션 데이터베이스에 물론 액세스 할 수 있다고 가정합니다. 해결

+0

rake db : migrate를 실행했습니다. 그것은 나에게 아무것도주지 않았다. 나는 rake db : rollback을 돌렸다. 그것은 말한다. 'users'테이블의 'index_users_on_confirmation_token'인덱스 이름이 존재하지 않습니다. – riship89

+0

해당 RAILS_ENV 명령을 실행할 위치는 무엇입니까? – riship89

+2

Heroku가 기본적으로 프로덕션 환경에 있어야하며 database.yml을 자신의 –