Reputation: 2669
db:migrate doesn't run when I push my app up to migrations. I'm told it's supposed to detect new migrations and execute db:migration during the push/deploy, but that's simply not happening.
Rails 4 app on ruby 1.9.3.
Here's an example where I had two pending migrations. They're not migrated during the deploy, but they do run when I manually kick them off -- something is amiss.
$ git push heroku master
Warning: Permanently added the RSA host key for IP address '50.19.85.156' to the list of known hosts.
Counting objects: 91, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (66/66), done.
Writing objects: 100% (67/67), 7.26 KiB, done.
Total 67 (delta 45), reused 0 (delta 0)
-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-1.9.3
-----> Installing dependencies using Bundler version 1.3.2
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment
Using rake (10.1.0)
Using i18n (0.6.5)
Using minitest (4.7.5)
Using multi_json (1.8.2)
Using atomic (1.1.14)
Using thread_safe (0.1.3)
Using tzinfo (0.3.38)
Using activesupport (4.0.0)
Using builder (3.1.4)
Using erubis (2.7.0)
Using rack (1.5.2)
Using rack-test (0.6.2)
Using actionpack (4.0.0)
Using mime-types (1.25)
Using polyglot (0.3.3)
Using treetop (1.4.15)
Using mail (2.5.4)
Using actionmailer (4.0.0)
Using activemodel (4.0.0)
Using activerecord-deprecated_finders (1.0.3)
Using arel (4.0.0)
Using activerecord (4.0.0)
Using aegis (2.5.3)
Using authlogic (3.3.0)
Using bcrypt-ruby (3.0.1)
Using thor (0.18.1)
Using railties (4.0.0)
Using sass (3.2.12)
Using hike (1.2.3)
Using tilt (1.4.1)
Using sprockets (2.10.0)
Using sprockets-rails (2.0.1)
Using sass-rails (4.0.1)
Using bootstrap-sass-rails (3.0.0.3)
Using will_paginate (3.0.5)
Using bootstrap-will_paginate (0.0.10)
Using bourbon (2.1.3)
Using coffee-script-source (1.6.3)
Using execjs (2.0.2)
Using coffee-script (2.2.0)
Using coffee-rails (4.0.1)
Using jquery-rails (3.0.4)
Using json (1.8.1)
Using kgio (2.8.1)
Using libv8 (3.16.14.3)
Using pg (0.17.0)
Using bundler (1.3.2)
Using rails (4.0.0)
Using rails_serve_static_assets (0.0.1)
Using rails_stdout_logging (0.0.3)
Using rails_12factor (0.0.2)
Using raindrops (0.12.0)
Using rdoc (3.12.2)
Using ref (1.0.5)
Using sdoc (0.3.20)
Using therubyracer (0.12.0)
Using turbolinks (1.3.0)
Using uglifier (2.2.1)
Using unicorn (4.6.3)
Your bundle is complete! It was installed into ./vendor/bundle
Bundle completed (0.58s)
Cleaning up the bundler cache.
-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
Asset precompilation completed (12.30s)
Cleaning assets
-----> Discovering process types
Procfile declares types -> mailcatcher, server
Default types for Ruby -> console, rake, web, worker
-----> Compiled slug size: 32.6MB
-----> Launching... done, v55
http://lalalala.herokuapp.com deployed to Heroku
To [email protected]:lalalala.git
a936e5d..9ec7895 master -> master
$ heroku run bundle exec rake db:migrate ; heroku restart
Running `bundle exec rake db:migrate` attached to terminal... Enter your Heroku credentials.
up, run.9864
Migrating to AddDeletedAtToUsers (20131116225241)
== AddDeletedAtToUsers: migrating ============================================
-- add_column(:users, :deleted_at, :datetime)
-> 0.0315s
== AddDeletedAtToUsers: migrated (0.0326s) ===================================
Migrating to MakePhoneNumberNullable (20131116231841)
== MakePhoneNumberNullable: migrating ========================================
-- change_column(:users, :phone_number, :string, {:default=>nil, :null=>true})
-> 0.1158s
== MakePhoneNumberNullable: migrated (0.1207s) ===============================
Restarting dynos... done
Upvotes: 0
Views: 383
Reputation: 363
Heroku doesn't automatically run migrations.
It might be worth checking out the heroku_san gem, which you can configure to automatically run migrations for you when you deploy.
Upvotes: 2