heroku迁移拒绝在部署期间运行

时间:2013-11-17 01:23:46

标签: ruby-on-rails heroku

当我将我的应用程序推送到迁移时,

db:migrate不会运行。我被告知它应该检测新的迁移并在推/部署期间执行db:migration,但这根本就不会发生。

ruby​​ 1.9.3上的Rails 4 app。

以下是我有两个待处理迁移的示例。它们在部署期间不会迁移,但是当我手动启动它们时它们会运行 - 这有点不对。

    $ 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 git@heroku.com: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

1 个答案:

答案 0 :(得分:2)

Heroku不会自动运行迁移。

可能值得查看heroku_san gem,您可以将其配置为在部署时自动为您运行迁移。