1

解決済み:この問題が不思議なことに消えた方法の一部、これはherokuが生成したURLです

http://pacific-escarpment-9949.herokuapp.com/

30分前にエラーページが表示されたが、もう表示されない理由を誰かが詳しく説明していただければ幸いです。

ローカルで問題なく動作します。しかし、Herokuにプッシュすると、このエラーが発生します。

次のコマンドを使用したため、データベースに関係していると思います。

rails generate migration add_user_id_to_post integer (pseudocode, it worked fine)

私はすでに実行しています:$ heroku run rake db:migrate

ホームページのはずのページには、次のように表示されます。申し訳ありませんが、問題が発生しました。

以前にこの問題がありましたが、heroku run rake db:migrate を実行すると問題が解決しました。しかし、今回はそうではありません。親切に助けてください。私は今3時間立ち往生しています。ありがとうございました。

これが私のgitハブのレポです:https://github.com/nixor/blog

私の初心者を許してください、これらはすべて私にとって非常に2週間新しいものです。

nixor@unix:$ heroku run rake db:migrate
    Running `rake db:migrate` attached to terminal... up, run.1
    DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)
    DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)
    Connecting to database specified by DATABASE_URL
    Migrating to CreatePosts (20121124111726)
    ==  CreatePosts: migrating ====================================================
    -- create_table(:posts)
    NOTICE:  CREATE TABLE will create implicit sequence "posts_id_seq" for serial column "posts.id"
    NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "posts_pkey" for table "posts"
       -> 0.0215s
    ==  CreatePosts: migrated (0.0216s) ===========================================
    
    Migrating to CreateUsers (20121126134513)
    ==  CreateUsers: migrating ====================================================
    -- create_table(:users)
    NOTICE:  CREATE TABLE will create implicit sequence "users_id_seq" for serial column "users.id"
    NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "users_pkey" for table "users"
       -> 0.0121s
    ==  CreateUsers: migrated (0.0122s) ===========================================
    
    Migrating to AddUserIdToPosts (20121126173652)
    ==  AddUserIdToPosts: migrating ===============================================
    -- add_column(:posts, :user_id, :integer)
    rake aborted!
    An error has occurred, this and all later migrations canceled:
    
    PGError: ERROR:  column "user_id" of relation "posts" already exists
    : ALTER TABLE "posts" ADD COLUMN "user_id" integer
    /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:652:in `async_exec'
    /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:652:in `block in execute'
    /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
    /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
    /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
    /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `execute'
    /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:1025:in `add_column'
    /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:466:in `block in method_missing'
    /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:438:in `block in say_with_time'
    /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:438:in `say_with_time'
    /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:458:in `method_missing'
    /app/db/migrate/20121126173652_add_user_id_to_posts.rb:3:in `change'
    /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:407:in `block (2 levels) in migrate'
    /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:407:in `block in migrate'
    /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:129:in `with_connection'
    /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:389:in `migrate'
    /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:528:in `migrate'
    /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:720:in `block (2 levels) in migrate'
    /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:775:in `call'
    /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:775:in `block in ddl_transaction'
    /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
    /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/transactions.rb:208:in `transaction'
    /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:775:in `ddl_transaction'
    /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:719:in `block in migrate'
    /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:700:in `each'
    /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:700:in `migrate'
    /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:570:in `up'
    /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:551:in `migrate'
    /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/railties/databases.rake:179:in `block (2 levels) in <top (required)>'
    Tasks: TOP => db:migrate
    (See full trace by running task with --trace)
4

1 に答える 1

0

user_idは最初の移行ですでに定義されているため、投稿にuser_idを追加しても意味がありません。Postgresは正しくエラーを発生させています。

移行は変更されないため、移行を削除しても安全です。

于 2012-11-27T00:12:51.147 に答える