I'm trying to run heroku run rake db:migrate, but I get the following:
Running rake db:migrate attached to terminal... up, run.7
And that's it - Migration is not happening!
Although I have set up everything alright - development as sqlite3 and production as pg.
And previously all the migrations worked just fine. (rails 3.1. app )
I'm not sure what is happening here.
Here are the logs:
←[35m2012-01-08T11:25:22+00:00 app[run.8]:←[0m Awaiting client
←[35m2012-01-08T11:25:22+00:00 app[run.8]:←[0m Starting process with command `bu
ndle exec rake db:migrate`
←[35m2012-01-08T11:25:22+00:00 heroku[run.8]:←[0m State changed from starting to
up
←[35m2012-01-08T11:25:35+00:00 heroku[run.8]:←[0m State changed from up to compl
ete
←[35m2012-01-08T11:25:35+00:00 heroku[run.8]:←[0m Process exited
I don't see any errors.
Has anybody came across with something similar ?
Thanks!
The reason for this was simply because the migration has already happened automatically after pushing the updated app to heroku.
Related
I have a Ruby on Rails application that is successfully running on Heroku.
I did some experimentation with RSpec and Cucumber, but at some point running the server locally failed with the message
Migrations are pending. To resolve this issue, run: bin/rake
db:migrate RAILS_ENV=development
I ran rake db:migrate:status and literally all 50 or so of my migrations are marked as "down", even ones created months ago:
When I try to run the command it gives me, it gives me
PG::DuplicateTable: ERROR: relation "artists" already exists
which is fair enough since it does, it's an old migration. So the problem is that it's not detecting that these migrations were already run.
Here's what I've tried:
A git reset to the last working state (my heroku instance)
Restarting Postgres, the rails server and my Mac
Running rake db:reset, as well as rake db:drop db:create db:migrate
None of which worked. I'm desperate to get my app back into a state where I can continue development on it.
I have a Rails app which I have recently pushed up to Heroku. When I try to migrate the database with:
heroku run rake db:migrate
I am getting the rake aborted! message and complains about a table that doesn't exist.
Locally, when I run the migrate command there are no issues so why is Heroku different?
I did experience this issue the last time I migrated on Heroku too - I ended up using:
heroku rake db:schema:load
to overcome the problem but I really want to get to the root of the problem so it stops happening.
Any suggestions?
EDIT: I know which migration file is at fault but is it safe to remove a file from the migrations folder?
I'm following along with some tutorials and they are teaching how to create and run migrations. All has been working so far but I have run in to a problem. But now when i have come back to it the migration will not work in the development database. I used rake db:migrate RAILS_ENV=production to see if my migrations work and on that database it can go through all the migrations and back down again with no problems are errors but when I run rake db:migrate RAILS_ENV=development it pauses for a few seconds then returns me to the console awaiting a command. No errors are shown or nothing is returned to show what it has done and when checking the DB nothing has changed. What can this be?
Use --trace
rake db:migrate --trace
Show your database.yml file please.
I pushed an update to my Rails app production server, and in the update there was a new database migration. I ran rake db:migrate and got the common error seen here. I ran the rake again in bundle exec bash and it was successful. But after restarting my apache server, I'm now getting the 500 Error page. This update worked fine on my localhost, and was mostly this update to the db with supporting changes in the according view and controller/routing.
I don't even know why this error appeared this time, as I have pushed db updates successfully before using only rake. Nonetheless, the rake was successful. The 500 error page only shows on pages that require that specific new ActiveRecord. Any ideas on how to debug?
EDIT: My problem was an extremely simple one. I merely forgot to include the environment with the rake:
bundle exec rake db:migrate RAILS_ENV=production
Unfortunately, it took quite a while to narrow that down, as I couldn't use IRB to check the db entries until I followed these steps.
Did you run rake db:migrate on your server? Also be sure to set the RAILS_ENV flag so your production database is updated:
rake db:migrate RAILS_ENV=production
I have two instances of my app: one for development, one for production. My development database is called snip_development and my production database is called snip.
I've been doing migrations all along in my development environment and it's been going just fine. I recently created a production instance of my app but rake db:migrate doesn't seem to have any effect. After I run rake db:migrate and log into my database server, I can see that snip_development has all the tables I expect it to but snip doesn't have any tables at all.
I suspect the problem is that rake db:migrate is running on snip_development instead of snip and that's why I'm not seeing anything happen.
How do I get my migrations to work on my production database?
Sometimes I forget about Google. The answer is this:
rake db:migrate RAILS_ENV=production
For me the answer above not works. I have to add bundle exec to make it works.
bundle exec rails db:migrate RAILS_ENV=production