如何处理迁移名称冲突? [英] How do I deal with migration name clashes?

查看:85
本文介绍了如何处理迁移名称冲突?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了购物车gem(Piggybak),创建了一个名为create_orders...的迁移...但是我不再使用该gem,并添加了一个迁移以删除所有与piggybak相关的表.

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.

但是,我正在尝试推出自己的购物车,当我创建一个名为create_order的新迁移时,尽管它具有不同的时间戳,但出现此错误:

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

所以...我将迁移重命名为create_non_piggybak_orders,现在出现此错误:

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?

推荐答案

打开迁移文件,并更改类的名称以匹配驼峰格式的文件,即:

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

class CreateNonPiggybakOrders < ActiveRecord::Migration

这篇关于如何处理迁移名称冲突?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆