How do I deal with migration name clashes?

牧云@^-^@ 提交于 2019-12-11 06:53:40

问题


I installed a shopping cart gem (Piggybak), that created a migration called create_orders......but I am no longer using that gem, and have added a migration to drop all tables related to piggybak.

However, I am trying to roll my own shopping cart and when I created a new migration called create_order even though it has a different timestamp, I am getting this error:

$ rake db:migrate
[RailsAdmin] RailsAdmin initialization disabled by default. Pass SKIP_RAILS_ADMIN_INITIALIZER=false if you need it.
rake aborted!
Multiple migrations have the name CreateOrders

So...I renamed the migration to create_non_piggybak_orders and am now getting this error:

rake aborted!
An error has occurred, this and all later migrations canceled:

uninitialized constant CreateNonPiggybakOrders/.rvm/gems/ruby-2.0.0-p0@myapp/gems/activesupport-3.2.13/lib/active_support/inflector/methods.rb:230:in `block in constantize'

What's the best approach to handling this situation?


回答1:


Open the migration file and change the name of the class to match the file in camelcase, that is:

class CreateNonPiggybakOrders < ActiveRecord::Migration



来源:https://stackoverflow.com/questions/17157887/how-do-i-deal-with-migration-name-clashes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!