41166

heroku migrations silently failing

Question:

Note: this is my first time configuring a rails application, deploying a rails app and setting up a database. I very well might be doing something obviously stupid.

I have a working rails application setup with postgres 9.3. I can run migrations, run my server locally and get a running application locally.

I pushed my code up to heroku and at one point it ran. Now when I run the heroku console it shows that my database is totally empty and I cannot figure out how to recreate it.

I am using v 0.17.1 of the pg gem.

Here are the steps I have taken.

1) Created my database.yml

development: adapter: postgresql encoding: unicode database: fr_development pool: 5 username: user password: password test: adapter: postgresql encoding: unicode database: fr_test pool: 5 username: user password: password production: url: <%= ENV['DATABASE_URL'] %>

1.5) setup my heroku account and installed papertrail

2) Made sure my schema.rb and all migrations are under source control.

3) ran "git push heroku master"

4) ran "heroku run db:drop db:setup --app app" or alternately sometime "heroku pg:reset DATABASE_URL"

5) ran "heroku run rake db:migrate --app app"

6) ran "heroku restart --app app"

Basically no matter what I run, all i get in papertrail is:

Nov 09 11:19:50 app heroku/api: Starting process with command `bundle exec rake db:drop db:create db:migrate RAILS_ENV=production` by email@gmail.com Nov 09 11:19:53 app heroku/run.3003: Awaiting client Nov 09 11:19:53 app heroku/run.3003: Starting process with command `bundle exec rake db:drop db:create db:migrate RAILS_ENV=production` Nov 09 11:19:53 app heroku/run.3003: State changed from starting to up Nov 09 11:19:54 app heroku/run.3003: Process exited with status 0 Nov 09 11:19:54 app heroku/run.3003: State changed from up to complete

And then if I hit my server Ill get an error that one of my relations doesnt exist.

If I "heroku run console" and try to run any of my tables it will say they dont exist.

One thing I no nothing about and am having a hard time finding resources to learn about is proper configurations for bin directory stuff. I have not touched

my bin/bundle is totally empty

#!bin/rails begin load File.expand_path("../spring", __FILE__) rescue LoadError end APP_PATH = File.expand_path('../../config/application', __FILE__) require_relative '../config/boot' require 'rails/commands'

.

#bin/rake begin load File.expand_path("../spring", __FILE__) rescue LoadError end require_relative '../config/boot' require 'rake' Rake.application.run

.

#bin/spring unless defined?(Spring) require "rubygems" require "bundler" if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ spring \((.*?)\)$.*?^$/m) ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR) ENV["GEM_HOME"] = "" Gem.paths = ENV gem "spring", match[1] require "spring/binstub" end end

if I run heroku pg:info i get

HEROKU_POSTGRESQL_ONYX_URL (DATABASE_URL) Plan: Hobby-dev Status: Available Connections: 1/20 PG Version: 9.3.3 Created: 2014-11-06 04:08 UTC Data Size: 6.5 MB Tables: 0 Rows: 0/10000 (In compliance) Fork/Follow: Unsupported Rollback: Unsupported

One last thing that may be relevant I keep seeing this stack trace in paper trail although I'm not sure if it is just what happens when I reset the app:

[2014-11-10 03:39:58] FATAL SignalException: SIGTERM Nov 09 19:39:58 app app/web.1: /app/vendor/ruby-2.1.4/lib/ruby/2.1.0/webrick/server.rb:170:in `select' Nov 09 19:39:58 app app/web.1: /app/vendor/ruby-2.1.4/lib/ruby/2.1.0/webrick/server.rb:170:in `block in start' Nov 09 19:39:58 app app/web.1: /app/vendor/ruby-2.1.4/lib/ruby/2.1.0/webrick/server.rb:32:in `start' Nov 09 19:39:58 app app/web.1: /app/vendor/ruby-2.1.4/lib/ruby/2.1.0/webrick/server.rb:160:in `start' Nov 09 19:39:58 app app/web.1: /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/handler/webrick.rb:14:in `run' Nov 09 19:39:58 app app/web.1: /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/server.rb:264:in `start' Nov 09 19:39:58 app app/web.1: /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.5/lib/rails/commands/server.rb:69:in `start'

I have really tried to debug this one but I am out of ideas. Any help would be greatly appreciated.

other note: I setup postgres for the first time right before this. I was mucking around with it alot destorying and creating users and destroying and creating tables but I got everything back to a functional state locally. Don't know if that could somehow play into this.

Answer1:

Just to make sure, if you haven't already, first run:

heroku run rake db:migrate

And if then if that doesn't work:

heroku pg:reset

Followed by the heroku run rake db:migrate again.

By the way, I don't think Heroku gives you permission to to drop or create. Thus they've implemented pg:reset.

I found the devcenter doc that mentions permissions for dropping and creating and on using pg:reset here: <a href="https://devcenter.heroku.com/articles/rake" rel="nofollow">https://devcenter.heroku.com/articles/rake</a>

Recommend

  • How to sort by name `docker service ls`
  • apache won't start
  • How to generate a range of nonweekend dates using tools available in bash?
  • Is it possible to plot two variables using a third one as filter in R?
  • babeljs doesn't transpile extended classes properly [duplicate]
  • index name too long to rollback migration
  • How can I cons a list of pairs on to auto-mode-alist?
  • Using ENV files in production on Heroku
  • Amazon s3 – 403 Forbidden with Correct Bucket Policy
  • Is there any kind of jQuery.browser fallback?
  • Why won't my rails spec run?
  • OAuth2 flow for mobile app
  • Writing to Ontotext GraphDB using Jena
  • How to use : function in H2O ddply, R?
  • Ruby and class variables in inherit class
  • Insertion large number of Entities into SQL Server 2012 [duplicate]
  • Java : How to tint this PNG programmatically?
  • Avoid registering duplicate broadcast receivers in Android
  • Deploying a CodeRush plugin from the Community Site
  • Portable JRE on Linux - possible?
  • Retaining data after updating application
  • Most efficient way to move table rows from one table to another
  • HttpListener.IsSupported is false on XP SP3
  • How to get listview position?
  • How to retrieve information from antrun back to maven?
  • Connect .sks to skscene.h
  • jQuery ready not fired after rails link_to is clicked
  • How to test if a URL from an Eclipse bundle is a directory?
  • How to install a .deb file on a jailbroken iphone programmatically?
  • How to delay loading a property with linq to sql external mapping?
  • PHPUnit_Framework_TestCase class is not available. Fix… - Makegood , Eclipse
  • Jenkins: How To Build multiple projects from a TFS repository?
  • How do I fake an specific browser client when using Java's Net library?
  • Sony Xperia Z Tablet not found by adb
  • How would I use PHP exceptions to define a redirect?
  • Apache 2.4 - remove | delete | uninstall
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Cannot Parse HTML Data Using Android / JSOUP