u16suzuの blog

日々学んだことのメモブログです。

プロダクション環境でマイグレーション時に superclass mismatch for class Word エラーが発生した

[sakura] RAILS_ENV=production bundle exec rake db:migrate --trace                                                                             
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
rake aborted!
An error has occurred, all later migrations canceled:

superclass mismatch for class Word
/home/u16suzu/fedelini/db/migrate/20130622093909_word.rb:1:in `<top (required)>'

マイグレーションクラスの名前ががモデルの名前と被っていたので発生した。

db/migrate/20130622093909_word.rb

class Word < ActiveRecord::Migration
  def change
    add_column :words, :collect_count, :integer, default: 0, null: false
    add_column :words, :quiz_count, :integer, default: 0, null: false
  end
end

WordクラスへのマイグレションがWordという落ちでした。 しかし、development だと発生しないのに、 production だと発生した。謎。