Created
September 20, 2016 19:51
Revisions
-
chrisroos created this gist
Sep 20, 2016 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,184 @@ This demonstrates the problem with trying to run `rake db:migrate` as part of the slug compilation process when the an app is first deployed to Heroku. ```bash # Create new Rails app $ rails new --database=postgresql testing-migrations $ git init $ git add . $ git commit -m 'Add empty Rails project' # Use scaffolding to create a database migration $ rails g scaffold person name:string $ git add . $ git commit -m 'Add person scaffolding' # Create Heroku app $ heroku apps:create Creating app... done, ⬢ calm-ridge-11009 https://calm-ridge-11009.herokuapp.com/ | https://git.heroku.com/calm-ridge-11009.git # Set Heroku app to use Ruby buildpack $ heroku buildpacks:set heroku/ruby Buildpack set. Next release on calm-ridge-11009 will use heroku/ruby. Run git push heroku master to create a new release using this buildpack. # Add Rake buildpack to Heroku app $ heroku buildpacks:add https://github.com/gunpowderlabs/buildpack-ruby-rake-deploy-tasks Buildpack added. Next release on calm-ridge-11009 will use: 1. heroku/ruby 2. https://github.com/gunpowderlabs/buildpack-ruby-rake-deploy-tasks Run git push heroku master to create a new release using these buildpacks. # Configure Rake buildpack to run `rake db:migrate` $ heroku config:set DEPLOY_TASKS=db:migrate Setting DEPLOY_TASKS and restarting ⬢ calm-ridge-11009... done, v3 DEPLOY_TASKS: db:migrate # Deploy the app # Observe that it fails because the database doesn't appear to be available $ git push heroku master Counting objects: 101, done. Delta compression using up to 4 threads. Compressing objects: 100% (87/87), done. Writing objects: 100% (101/101), 22.63 KiB | 0 bytes/s, done. Total 101 (delta 8), reused 0 (delta 0) remote: Compressing source files... done. remote: Building source: remote: remote: -----> Ruby app detected remote: -----> Compiling Ruby/Rails remote: -----> Using Ruby version: ruby-2.2.4 remote: -----> Installing dependencies using bundler 1.11.2 remote: Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment remote: Fetching gem metadata from https://rubygems.org/........... remote: Fetching version metadata from https://rubygems.org/... remote: Fetching dependency metadata from https://rubygems.org/.. remote: Installing i18n 0.7.0 remote: Installing json 1.8.3 with native extensions remote: Installing rake 11.3.0 remote: Installing minitest 5.9.0 remote: Installing thread_safe 0.3.5 remote: Installing builder 3.2.2 remote: Installing erubis 2.7.0 remote: Installing mini_portile2 2.1.0 remote: Installing pkg-config 1.1.7 remote: Installing rack 1.6.4 remote: Installing mime-types-data 3.2016.0521 remote: Installing arel 6.0.3 remote: Installing coffee-script-source 1.10.0 remote: Installing execjs 2.7.0 remote: Installing thor 0.19.1 remote: Installing concurrent-ruby 1.0.2 remote: Using bundler 1.11.2 remote: Installing multi_json 1.12.1 remote: Installing pg 0.18.4 with native extensions remote: Installing sass 3.4.22 remote: Installing tilt 2.0.5 remote: Installing turbolinks-source 5.0.0 remote: Installing tzinfo 1.2.2 remote: Installing rdoc 4.2.2 remote: Installing nokogiri 1.6.8 with native extensions remote: Installing rack-test 0.6.3 remote: Installing mime-types 3.1 remote: Installing coffee-script 2.4.1 remote: Installing uglifier 3.0.2 remote: Installing sprockets 3.7.0 remote: Installing turbolinks 5.0.1 remote: Installing activesupport 4.2.7.1 remote: Installing sdoc 0.4.1 remote: Installing mail 2.6.4 remote: Installing rails-deprecated_sanitizer 1.0.3 remote: Installing globalid 0.3.7 remote: Installing activemodel 4.2.7.1 remote: Installing jbuilder 2.6.0 remote: Installing activejob 4.2.7.1 remote: Installing activerecord 4.2.7.1 remote: Installing rails-dom-testing 1.0.7 remote: Installing loofah 2.0.3 remote: Installing rails-html-sanitizer 1.0.3 remote: Installing actionview 4.2.7.1 remote: Installing actionpack 4.2.7.1 remote: Installing railties 4.2.7.1 remote: Installing actionmailer 4.2.7.1 remote: Installing sprockets-rails 3.2.0 remote: Installing coffee-rails 4.1.1 remote: Installing jquery-rails 4.2.1 remote: Installing rails 4.2.7.1 remote: Installing sass-rails 5.0.6 remote: Bundle complete! 12 Gemfile dependencies, 52 gems now installed. remote: Gems in the groups development and test were not installed. remote: Bundled gems are installed into ./vendor/bundle. remote: Post-install message from rdoc: remote: Depending on your version of ruby, you may need to install ruby rdoc/ri data: remote: <= 1.8.6 : unsupported remote: = 1.8.7 : gem install rdoc-data; rdoc-data --install remote: = 1.9.1 : gem install rdoc-data; rdoc-data --install remote: >= 1.9.2 : nothing to do! Yay! remote: Bundle completed (27.80s) remote: Cleaning up the bundler cache. remote: -----> Preparing app for Rails asset pipeline remote: Running: rake assets:precompile remote: I, [2016-09-20T19:46:28.469317 #903] INFO -- : Writing /tmp/build_153d6064cc62d6c97ec023b5b72c86c8/public/assets/application-32aca96fccef5b517f233b349393ff0335e17dd66d613cfc701f61bf0d230635.js remote: I, [2016-09-20T19:46:28.469822 #903] INFO -- : Writing /tmp/build_153d6064cc62d6c97ec023b5b72c86c8/public/assets/application-32aca96fccef5b517f233b349393ff0335e17dd66d613cfc701f61bf0d230635.js.gz remote: I, [2016-09-20T19:46:28.499662 #903] INFO -- : Writing /tmp/build_153d6064cc62d6c97ec023b5b72c86c8/public/assets/application-0723cb9a2dd5a514d954f70e0fe0b89f6f9f1ae3a375c182f43b5f2b57e9c869.css remote: I, [2016-09-20T19:46:28.499814 #903] INFO -- : Writing /tmp/build_153d6064cc62d6c97ec023b5b72c86c8/public/assets/application-0723cb9a2dd5a514d954f70e0fe0b89f6f9f1ae3a375c182f43b5f2b57e9c869.css.gz remote: Asset precompilation completed (3.85s) remote: Cleaning assets remote: Running: rake assets:clean remote: remote: ###### WARNING: remote: Include 'rails_12factor' gem to enable all platform features remote: See https://devcenter.heroku.com/articles/rails-integration-gems for more information. remote: remote: ###### WARNING: remote: You have not declared a Ruby version in your Gemfile. remote: To set your Ruby version add this line to your Gemfile: remote: ruby '2.2.4' remote: # See https://devcenter.heroku.com/articles/ruby-versions for more information. remote: remote: ###### WARNING: remote: No Procfile detected, using the default web server. remote: We recommend explicitly declaring how to boot your server process via a Procfile. remote: https://devcenter.heroku.com/articles/ruby-default-web-server remote: remote: -----> Rake app detected remote: rake aborted! remote: PG::ConnectionBad: could not connect to server: No such file or directory remote: Is the server running locally and accepting remote: connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"? remote: /tmp/build_153d6064cc62d6c97ec023b5b72c86c8/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize' remote: /tmp/build_153d6064cc62d6c97ec023b5b72c86c8/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `new' remote: /tmp/build_153d6064cc62d6c97ec023b5b72c86c8/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect' remote: /tmp/build_153d6064cc62d6c97ec023b5b72c86c8/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize' remote: /tmp/build_153d6064cc62d6c97ec023b5b72c86c8/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new' remote: /tmp/build_153d6064cc62d6c97ec023b5b72c86c8/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection' remote: /tmp/build_153d6064cc62d6c97ec023b5b72c86c8/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection' remote: /tmp/build_153d6064cc62d6c97ec023b5b72c86c8/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection' remote: /tmp/build_153d6064cc62d6c97ec023b5b72c86c8/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection' remote: /tmp/build_153d6064cc62d6c97ec023b5b72c86c8/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout' remote: /tmp/build_153d6064cc62d6c97ec023b5b72c86c8/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout' remote: /tmp/build_153d6064cc62d6c97ec023b5b72c86c8/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection' remote: /tmp/build_153d6064cc62d6c97ec023b5b72c86c8/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection' remote: /tmp/build_153d6064cc62d6c97ec023b5b72c86c8/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:571:in `retrieve_connection' remote: /tmp/build_153d6064cc62d6c97ec023b5b72c86c8/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.7.1/lib/active_record/connection_handling.rb:113:in `retrieve_connection' remote: /tmp/build_153d6064cc62d6c97ec023b5b72c86c8/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.7.1/lib/active_record/connection_handling.rb:87:in `connection' remote: /tmp/build_153d6064cc62d6c97ec023b5b72c86c8/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:916:in `initialize' remote: /tmp/build_153d6064cc62d6c97ec023b5b72c86c8/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:823:in `new' remote: /tmp/build_153d6064cc62d6c97ec023b5b72c86c8/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:823:in `up' remote: /tmp/build_153d6064cc62d6c97ec023b5b72c86c8/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:801:in `migrate' remote: /tmp/build_153d6064cc62d6c97ec023b5b72c86c8/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:137:in `migrate' remote: /tmp/build_153d6064cc62d6c97ec023b5b72c86c8/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.7.1/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>' remote: /tmp/build_153d6064cc62d6c97ec023b5b72c86c8/vendor/bundle/ruby/2.2.0/gems/rake-11.3.0/exe/rake:27:in `<top (required)>' remote: Tasks: TOP => db:migrate remote: (See full trace by running task with --trace) remote: ! Push rejected, failed to compile Rake app. remote: remote: ! Push failed remote: Verifying deploy... remote: remote: ! Push rejected to calm-ridge-11009. remote: To https://git.heroku.com/calm-ridge-11009.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/calm-ridge-11009.git' ```