迁移在生产中失败,但在开发中按预期运行。
... # everything to
20120709174326_add_subject_to_campaigns.rb # here runs fine.
20120711001125_set_default_value_for_publishable_in_newsletter.rb # <- this fails.
20120711010818_set_default_value_for_publishable_in_contents.rb
20120711010855_set_default_value_for_published_in_editions.rb
20120711191427_add_newsletter_date_to_newsletters.rb
20120711194230_rename_cm_campaign_sent_at_in_campaigns.rb
迁移错误如下所示:
-bash> heroku run rake db:migrate --remote staging
Running rake db:migrate attached to terminal... up, run.1
== SetDefaultValueForPublishableInNewsletter: migrating ======================
-- change_column(:newsletters, :publishable, :boolean, {:default=>false})
-> 0.1554s
rake aborted!
An error has occurred, this and all later migrations canceled:
undefined method `newsletter_date' for #<Newsletter:0x00000005961bd0>
问题是,newsletter_date 直到以后才添加,那么为什么它这么快就失败/提到它呢?它在开发中运行得非常好。