2016-06-13 20 views
0

私はherokuを使用して私のレールアプリを展開しています。私はheroku run rake db:seedというコマンドを実行して、生産に何らかのデータをシードしようとしています。ただし、コマンドは機能していません。私は生産にファイルをシードすることができません。 seeds.rbファイルを以下に示します。herokuを使用して運用データベースにデータを書き込むことはできません

# This file should contain all the record creation needed to seed the database with its default values. 
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). 
# 
# Examples: 
# 
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) 
# Mayor.create(name: 'Emanuel', city: cities.first) 

# end 


    5.times do    
    Scoreboard.create!(name_of_scoreboard: "scoreboard_abc", 
         name_of_organization: "abcdef", 
         name_of_activity: "ghijklmn", 
         user_id: 1, 
         states: "state", 
         country: "state", 
         cities: "state") 
    end 

このコマンドを実行すると、端末に次のメッセージが表示されます。

$ heroku run rake db:seed 
    Running rake db:seed on ⬢ app... up, run.4751 
     ActiveRecord::SchemaMigration Load (2.0ms) SELECT "schema_migrations".* FROM "schema_migrations" 

I run `heroku restart` but the objects isn't seeded in the production database. I have tried seeding this file in development and it works perfectly. I am not sure what's wrong. 

running heroku run rake db:setup gives me the following error 

DETAIL: User does not have CONNECT privilege. 
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize' 
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `new' 
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect' 
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize' 
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new' 
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection' 
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:436:in `new_connection' 
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:446:in `checkout_new_connection' 
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection' 
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout' 
/app/vendor/ruby-2.2.4/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize' 
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout' 
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection' 
/app/vendor/ruby-2.2.4/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize' 
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection' 
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:565:in `retrieve_connection' 
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_handling.rb:113:in `retrieve_connection' 

I also get the following errors. 
psql:/app/db/structure.sql:955: ERROR: multiple primary keys for table "mailboxer_conversation_opt_outs" are not allowed 
psql:/app/db/structure.sql:963: ERROR: multiple primary keys for table "mailboxer_conversations" are not allowed 
psql:/app/db/structure.sql:971: ERROR: multiple primary keys for table "mailboxer_notifications" are not allowed 
psql:/app/db/structure.sql:979: ERROR: multiple primary keys for table "mailboxer_receipts" are not allowed 
psql:/app/db/structure.sql:987: ERROR: multiple primary keys for table "managers" are not allowed 
psql:/app/db/structure.sql:995: ERROR: multiple primary keys for table "pg_search_documents" are not allowed 
psql:/app/db/structure.sql:1003: ERROR: multiple primary keys for table "pictures" are not allowed 
psql:/app/db/structure.sql:1011: ERROR: multiple primary keys for table "requests" are not allowed 
psql:/app/db/structure.sql:1027: ERROR: multiple primary keys for table "scoreboards" are not allowed 
psql:/app/db/structure.sql:1035: ERROR: multiple primary keys for table "statuses" are not allowed 
psql:/app/db/structure.sql:1043: ERROR: multiple primary keys for table "team_matches" are not allowed 
psql:/app/db/structure.sql:1051: ERROR: multiple primary keys for table "team_members" are not allowed 
psql:/app/db/structure.sql:1059: ERROR: multiple primary keys for table "teams" are not allowed 
psql:/app/db/structure.sql:1067: ERROR: multiple primary keys for table "topics" are not allowed 
psql:/app/db/structure.sql:1075: ERROR: multiple primary keys for table "users" are not allowed 
psql:/app/db/structure.sql:1082: ERROR: relation "index_categories_on_scoreboard_id" already exists 
psql:/app/db/structure.sql:1089: ERROR: relation "index_documents_on_category_id" already exists 
psql:/app/db/structure.sql:1096: ERROR: relation "index_events_on_scoreboard_id" already exists 
psql:/app/db/structure.sql:1103: ERROR: relation "index_favourites_on_scoreboard_id" already exists 
psql:/app/db/structure.sql:1110: ERROR: relation "index_favourites_on_user_id" already exists 
psql:/app/db/structure.sql:1117: ERROR: relation "index_favourites_on_user_id_and_scoreboard_id" already exists 
psql:/app/db/structure.sql:1124: ERROR: relation "index_invitations_on_scoreboard_ 

私は既に存在する移行ファイルを実行していると思います。その結果、私は一意性のエラーを取得しています。

答えて

0

移行は保留中です。あなたが試すことができます。

Heroku run rake db:migrate db:seed 
+0

を次の手順をお試しください:リセットDATABASEを、Herokuのは、すくいデシベルを実行します。ために、シード:移行し、HerokuのDBを。私はheroku run rake db:migrateを実行したので、移行は保留中であってはなりませんでした。私はあなたの命令を試みたが、うまくいかなかった。 – kpaul

0

を私はHerokuのPGの走った、

heroku run rake db:schema:load 
heroku run rake db:migrate 
heroku run rake db:seed 
+0

schema.rbファイルが存在しません。私はpostgresql全文検索のためにtsvectorカラムを使用しているので、それをstruct.sqlに変更しました。ファイルが存在しないため、最初のコマンドは機能しません。私はそれを試して、私は次のエラーがある。 /app/db/schema.rbはまだ存在しません。 'rake db:migrate'を実行して作成します。 – kpaul

+0

heroku run rake db:setupを実行してからherokuを実行してみてくださいrake db:seed –

+0

私は私が得たエラーで質問を更新します – kpaul

関連する問題