2

我正在新工作站上设置现有的 rails 应用程序。当我尝试时rake db:migrate,在尝试创建第一个表之前,我得到了这个奇怪的错误(是的,我从 开始rake db:create):

$ bundle exec rake db:migrate
rake aborted!
Mysql2::Error: Table 'myapp_dev.usage_roles' doesn't exist: SHOW FULL FIELDS FROM `usage_roles`
# ... followed by a long stack trace

我无法猜测为什么 rake 任务试图在任何表存在之前显示任何表中的字段。我什至没有在应用程序中看到太多提及此表。这是完整的grep:

$ grep -r usage_roles .
Binary file ./.git/index matches
./app/models/usage/role.rb:  self.table_name = 'usage_roles'
./app/models/usage/user.rb:    where(" usage_roles.name in (?)", Usage::Role::SUPPORT_ROLES)
./coverage/index.html:          <code class="ruby">  self.table_name = 'usage_roles'</code>
./coverage/index.html:          <code class="ruby">    where(&quot; usage_roles.name in (?)&quot;, Usage::Role::SUPPORT_ROLES)</code>
./db/migrate/20130112104233_create_usage_roles.rb:    execute('CREATE VIEW usage_roles AS SELECT 
./db/migrate/20130112104233_create_usage_roles.rb:            * FROM clu_enums.usage_roles;')
./db/migrate/20130112104233_create_usage_roles.rb:    execute('DROP VIEW IF EXISTS usage_roles;')
4

1 回答 1

2

我认为您的问题与 Factorygirl 处理数据库的方式直接相关。当您设置factory_girl_rails时,require:false这似乎是解决方案。

看看这个FactoryGirl 搞砸了 rake db:migrate 过程

于 2013-06-03T18:53:47.033 回答