marcamillion
marcamillion

Reputation: 33755

How do I deal with migration name clashes?

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?

Upvotes: 1

Views: 337

Answers (1)

boulder
boulder

Reputation: 3266

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

class CreateNonPiggybakOrders < ActiveRecord::Migration

Upvotes: 1

Related Questions