Search code examples
ruby-on-railsrubygitherokuheroku-postgres

Unable to push migrations to Heroku


I have a rails app on Heroku. I can connect to it, push builds, and see that it's running.

The problem: I am unable to push builds that include migrations in the db>migrate folder. Any attempt to do so gives me an error of

remote: Run `bin/rails db:migrate` to update your database then try again. remote: You have 3 pending migrations: remote: 20210326003113 CreateUsers remote: 20210326004504 CreateAlerts remote: 20210326004819 CreateContacts remote: Waiting for release.... failed. To https://git.heroku.com/*appname* 3dca123..cc0f499 master -> master

I ran my migrations locally, committed, tested them locally (they work), then pushed to heroku with the same response as above.

I can run heroku run bin/rails db:migrate which gives me a response of a bunch of warnings.

// ♥  heroku run bin/rails db:migrate -a *app name*
Running bin/rails db:migrate on ⬢ *app name*... up, run.1211 (Free)
/app/vendor/bundle/ruby/2.6.0/gems/bundler-2.2.11/lib/bundler/rubygems_integration.rb:12: warning: already initialized constant Bundler::RubygemsIntegration::EXT_LOCK
/app/vendor/ruby-2.6.1/lib/ruby/2.6.0/bundler/rubygems_integration.rb:12: warning: previous definition of EXT_LOCK was here
/app/vendor/bundle/ruby/2.6.0/gems/bundler-2.2.11/lib/bundler/version.rb:4: warning: already initialized constant Bundler::VERSION
/app/vendor/ruby-2.6.1/lib/ruby/2.6.0/bundler/version.rb:10: warning: previous definition of VERSION was here
/app/vendor/bundle/ruby/2.6.0/gems/bundler-2.2.11/lib/bundler/constants.rb:4: warning: already initialized constant Bundler::WINDOWS
/app/vendor/ruby-2.6.1/lib/ruby/2.6.0/bundler/constants.rb:4: warning: previous definition of WINDOWS was here
/app/vendor/bundle/ruby/2.6.0/gems/bundler-2.2.11/lib/bundler/constants.rb:5: warning: already initialized constant Bundler::FREEBSD
/app/vendor/ruby-2.6.1/lib/ruby/2.6.0/bundler/constants.rb:5: warning: previous definition of FREEBSD was here
/app/vendor/bundle/ruby/2.6.0/gems/bundler-2.2.11/lib/bundler/constants.rb:6: warning: already initialized constant Bundler::NULL
/app/vendor/ruby-2.6.1/lib/ruby/2.6.0/bundler/constants.rb:6: warning: previous definition of NULL was here
/app/vendor/bundle/ruby/2.6.0/gems/bundler-2.2.11/lib/bundler/current_ruby.rb:12: warning: already initialized constant Bundler::CurrentRuby::KNOWN_MINOR_VERSIONS
/app/vendor/ruby-2.6.1/lib/ruby/2.6.0/bundler/current_ruby.rb:12: warning: previous definition of KNOWN_MINOR_VERSIONS was here
/app/vendor/bundle/ruby/2.6.0/gems/bundler-2.2.11/lib/bundler/current_ruby.rb:25: warning: already initialized constant Bundler::CurrentRuby::KNOWN_MAJOR_VERSIONS
/app/vendor/ruby-2.6.1/lib/ruby/2.6.0/bundler/current_ruby.rb:24: warning: previous definition of KNOWN_MAJOR_VERSIONS was here
/app/vendor/bundle/ruby/2.6.0/gems/bundler-2.2.11/lib/bundler/current_ruby.rb:27: warning: already initialized constant Bundler::CurrentRuby::KNOWN_PLATFORMS
/app/vendor/ruby-2.6.1/lib/ruby/2.6.0/bundler/current_ruby.rb:26: warning: previous definition of KNOWN_PLATFORMS was here

Checking the logs, it tells me it could not create a user because my user table doesn't exist. User table doesn't exist because there are no migrations. Using heroku run rake db:migrate does nothing because the build on Heroku contains no migrations. I cannot push a build with migrations because it tells me I have pending migrations.

Any assistance with this catch-22 would be lovely. Can readily post the logs if requested.


Solution

  • Solution was inside of my Procfile. I needed to use bundle exec rails s. Before I was using release: bin/rails db:migrate