我在新工作站上设置现有的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(" usage_roles.name in (?)", 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;')
答案 0 :(得分:2)
我认为您的问题与Factorygirl如何处理数据库直接相关。将factory_girl_rails
设置为require:false
时,似乎是解决方案。