我正在尝试为rails应用程序设置开发环境,但无法运行迁移,因为出现以下错误:
D, [2018-10-15T19:09:17.732136 #1] DEBUG -- : Category Load (0.6ms) SELECT `categories`.* FROM `categories` WHERE (categories.parent_id IS NULL)
rake aborted!
ActiveRecord::StatementInvalid: Mysql2::Error: Table 'mysite_dev.categories' doesn't exist: SELECT `categories`.* FROM `categories` WHERE (categories.parent_id IS NULL)
/usr/local/bundle/gems/mysql2-0.4.10/lib/mysql2/client.rb:120:in `_query'
/usr/local/bundle/gems/mysql2-0.4.10/lib/mysql2/client.rb:120:in `block in query'
/usr/local/bundle/gems/mysql2-0.4.10/lib/mysql2/client.rb:119:in `handle_interrupt'
/usr/local/bundle/gems/mysql2-0.4.10/lib/mysql2/client.rb:119:in `query'
/usr/local/bundle/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:317:in `block in execute'
/usr/local/bundle/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract_adapter.rb:484:in `block in log'
/usr/local/bundle/gems/activesupport-4.2.10/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/usr/local/bundle/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract_adapter.rb:478:in `log'
/usr/local/bundle/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:317:in `execute'
/usr/local/bundle/gems/activerecord-4.2.10/lib/active_record/connection_adapters/mysql2_adapter.rb:217:in `execute'
/usr/local/bundle/gems/activerecord-4.2.10/lib/active_record/connection_adapters/mysql2_adapter.rb:221:in `exec_query'
/usr/local/bundle/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/database_statements.rb:356:in `select'
/usr/local/bundle/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/database_statements.rb:32:in `select_all'
/usr/local/bundle/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/query_cache.rb:70:in `select_all'
/usr/local/bundle/gems/activerecord-4.2.10/lib/active_record/querying.rb:39:in `find_by_sql'
/usr/local/bundle/gems/activerecord-4.2.10/lib/active_record/relation.rb:639:in `exec_queries'
/usr/local/bundle/gems/activerecord-4.2.10/lib/active_record/relation.rb:515:in `load'
/usr/local/bundle/gems/activerecord-4.2.10/lib/active_record/relation.rb:243:in `to_a'
/usr/local/bundle/gems/activerecord-4.2.10/lib/active_record/relation/delegation.rb:46:in `map'
/usr/src/app/app/routing/categories_constraint.rb:4:in `<class:CategoriesConstraint>'
/usr/src/app/app/routing/categories_constraint.rb:3:in `<top (required)>'
/usr/local/bundle/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:457:in `load'
/usr/local/bundle/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:457:in `block in load_file'
/usr/local/bundle/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:647:in `new_constants_in'
/usr/local/bundle/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:456:in `load_file'
/usr/local/bundle/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:354:in `require_or_load'
/usr/local/bundle/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:494:in `load_missing_constant'
/usr/local/bundle/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:184:in `const_missing'
/usr/src/app/config/routes.rb:334:in `block in <top (required)>'
/usr/local/bundle/gems/actionpack-4.2.10/lib/action_dispatch/routing/route_set.rb:432:in `instance_exec'
/usr/local/bundle/gems/actionpack-4.2.10/lib/action_dispatch/routing/route_set.rb:432:in `eval_block'
/usr/local/bundle/gems/actionpack-4.2.10/lib/action_dispatch/routing/route_set.rb:410:in `draw'
/usr/src/app/config/routes.rb:1:in `<top (required)>'
/usr/local/bundle/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:268:in `load'
/usr/local/bundle/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:268:in `block in load'
/usr/local/bundle/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:240:in `load_dependency'
/usr/local/bundle/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:268:in `load'
/usr/local/bundle/gems/railties-4.2.10/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
/usr/local/bundle/gems/railties-4.2.10/lib/rails/application/routes_reloader.rb:40:in `each'
/usr/local/bundle/gems/railties-4.2.10/lib/rails/application/routes_reloader.rb:40:in `load_paths'
/usr/local/bundle/gems/railties-4.2.10/lib/rails/application/routes_reloader.rb:16:in `reload!'
/usr/local/bundle/gems/railties-4.2.10/lib/rails/application/routes_reloader.rb:26:in `block in updater'
/usr/local/bundle/gems/activesupport-4.2.10/lib/active_support/file_update_checker.rb:75:in `execute'
/usr/local/bundle/gems/railties-4.2.10/lib/rails/application/routes_reloader.rb:27:in `updater'
/usr/local/bundle/gems/railties-4.2.10/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
/usr/local/bundle/gems/railties-4.2.10/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'
/usr/local/bundle/gems/railties-4.2.10/lib/rails/initializable.rb:30:in `instance_exec'
/usr/local/bundle/gems/railties-4.2.10/lib/rails/initializable.rb:30:in `run'
/usr/local/bundle/gems/railties-4.2.10/lib/rails/initializable.rb:55:in `block in run_initializers'
/usr/local/bundle/gems/railties-4.2.10/lib/rails/initializable.rb:54:in `run_initializers'
/usr/local/bundle/gems/railties-4.2.10/lib/rails/application.rb:352:in `initialize!'
/usr/src/app/config/environment.rb:5:in `<top (required)>'
/usr/local/bundle/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in `require'
/usr/local/bundle/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in `block in require'
/usr/local/bundle/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:240:in `load_dependency'
/usr/local/bundle/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in `require'
/usr/local/bundle/gems/railties-4.2.10/lib/rails/application.rb:328:in `require_environment!'
/usr/local/bundle/gems/railties-4.2.10/lib/rails/application.rb:457:in `block in run_tasks_blocks'
/usr/local/bundle/gems/bundler-1.16.6/lib/bundler/cli/exec.rb:74:in `load'
/usr/local/bundle/gems/bundler-1.16.6/lib/bundler/cli/exec.rb:74:in `kernel_load'
/usr/local/bundle/gems/bundler-1.16.6/lib/bundler/cli/exec.rb:28:in `run'
/usr/local/bundle/gems/bundler-1.16.6/lib/bundler/cli.rb:424:in `exec'
/usr/local/bundle/gems/bundler-1.16.6/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/bundle/gems/bundler-1.16.6/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/usr/local/bundle/gems/bundler-1.16.6/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
/usr/local/bundle/gems/bundler-1.16.6/lib/bundler/cli.rb:27:in `dispatch'
/usr/local/bundle/gems/bundler-1.16.6/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
/usr/local/bundle/gems/bundler-1.16.6/lib/bundler/cli.rb:18:in `start'
/usr/local/bundle/gems/bundler-1.16.6/exe/bundle:30:in `block in <top (required)>'
/usr/local/bundle/gems/bundler-1.16.6/lib/bundler/friendly_errors.rb:124:in `with_friendly_errors'
/usr/local/bundle/gems/bundler-1.16.6/exe/bundle:22:in `<top (required)>'
/usr/local/bundle/bin/bundle:104:in `load'
/usr/local/bundle/bin/bundle:104:in `<main>'
Mysql2::Error: Table 'mysite_dev.categories' doesn't exist
/usr/local/bundle/gems/mysql2-0.4.10/lib/mysql2/client.rb:120:in `_query'
/usr/local/bundle/gems/mysql2-0.4.10/lib/mysql2/client.rb:120:in `block in query'
/usr/local/bundle/gems/mysql2-0.4.10/lib/mysql2/client.rb:119:in `handle_interrupt'
/usr/local/bundle/gems/mysql2-0.4.10/lib/mysql2/client.rb:119:in `query'
/usr/local/bundle/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:317:in `block in execute'
/usr/local/bundle/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract_adapter.rb:484:in `block in log'
/usr/local/bundle/gems/activesupport-4.2.10/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/usr/local/bundle/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract_adapter.rb:478:in `log'
/usr/local/bundle/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:317:in `execute'
/usr/local/bundle/gems/activerecord-4.2.10/lib/active_record/connection_adapters/mysql2_adapter.rb:217:in `execute'
/usr/local/bundle/gems/activerecord-4.2.10/lib/active_record/connection_adapters/mysql2_adapter.rb:221:in `exec_query'
/usr/local/bundle/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/database_statements.rb:356:in `select'
/usr/local/bundle/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/database_statements.rb:32:in `select_all'
/usr/local/bundle/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/query_cache.rb:70:in `select_all'
/usr/local/bundle/gems/activerecord-4.2.10/lib/active_record/querying.rb:39:in `find_by_sql'
/usr/local/bundle/gems/activerecord-4.2.10/lib/active_record/relation.rb:639:in `exec_queries'
/usr/local/bundle/gems/activerecord-4.2.10/lib/active_record/relation.rb:515:in `load'
/usr/local/bundle/gems/activerecord-4.2.10/lib/active_record/relation.rb:243:in `to_a'
/usr/local/bundle/gems/activerecord-4.2.10/lib/active_record/relation/delegation.rb:46:in `map'
/usr/src/app/app/routing/categories_constraint.rb:4:in `<class:CategoriesConstraint>'
/usr/src/app/app/routing/categories_constraint.rb:3:in `<top (required)>'
/usr/local/bundle/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:457:in `load'
/usr/local/bundle/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:457:in `block in load_file'
/usr/local/bundle/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:647:in `new_constants_in'
/usr/local/bundle/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:456:in `load_file'
/usr/local/bundle/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:354:in `require_or_load'
/usr/local/bundle/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:494:in `load_missing_constant'
/usr/local/bundle/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:184:in `const_missing'
/usr/src/app/config/routes.rb:334:in `block in <top (required)>'
/usr/local/bundle/gems/actionpack-4.2.10/lib/action_dispatch/routing/route_set.rb:432:in `instance_exec'
/usr/local/bundle/gems/actionpack-4.2.10/lib/action_dispatch/routing/route_set.rb:432:in `eval_block'
/usr/local/bundle/gems/actionpack-4.2.10/lib/action_dispatch/routing/route_set.rb:410:in `draw'
/usr/src/app/config/routes.rb:1:in `<top (required)>'
/usr/local/bundle/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:268:in `load'
/usr/local/bundle/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:268:in `block in load'
/usr/local/bundle/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:240:in `load_dependency'
/usr/local/bundle/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:268:in `load'
/usr/local/bundle/gems/railties-4.2.10/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
/usr/local/bundle/gems/railties-4.2.10/lib/rails/application/routes_reloader.rb:40:in `each'
/usr/local/bundle/gems/railties-4.2.10/lib/rails/application/routes_reloader.rb:40:in `load_paths'
/usr/local/bundle/gems/railties-4.2.10/lib/rails/application/routes_reloader.rb:16:in `reload!'
/usr/local/bundle/gems/railties-4.2.10/lib/rails/application/routes_reloader.rb:26:in `block in updater'
/usr/local/bundle/gems/activesupport-4.2.10/lib/active_support/file_update_checker.rb:75:in `execute'
/usr/local/bundle/gems/railties-4.2.10/lib/rails/application/routes_reloader.rb:27:in `updater'
/usr/local/bundle/gems/railties-4.2.10/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
/usr/local/bundle/gems/railties-4.2.10/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'
/usr/local/bundle/gems/railties-4.2.10/lib/rails/initializable.rb:30:in `instance_exec'
/usr/local/bundle/gems/railties-4.2.10/lib/rails/initializable.rb:30:in `run'
/usr/local/bundle/gems/railties-4.2.10/lib/rails/initializable.rb:55:in `block in run_initializers'
/usr/local/bundle/gems/railties-4.2.10/lib/rails/initializable.rb:54:in `run_initializers'
/usr/local/bundle/gems/railties-4.2.10/lib/rails/application.rb:352:in `initialize!'
/usr/src/app/config/environment.rb:5:in `<top (required)>'
/usr/local/bundle/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in `require'
/usr/local/bundle/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in `block in require'
/usr/local/bundle/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:240:in `load_dependency'
/usr/local/bundle/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in `require'
/usr/local/bundle/gems/railties-4.2.10/lib/rails/application.rb:328:in `require_environment!'
/usr/local/bundle/gems/railties-4.2.10/lib/rails/application.rb:457:in `block in run_tasks_blocks'
/usr/local/bundle/gems/bundler-1.16.6/lib/bundler/cli/exec.rb:74:in `load'
/usr/local/bundle/gems/bundler-1.16.6/lib/bundler/cli/exec.rb:74:in `kernel_load'
/usr/local/bundle/gems/bundler-1.16.6/lib/bundler/cli/exec.rb:28:in `run'
/usr/local/bundle/gems/bundler-1.16.6/lib/bundler/cli.rb:424:in `exec'
/usr/local/bundle/gems/bundler-1.16.6/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/bundle/gems/bundler-1.16.6/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/usr/local/bundle/gems/bundler-1.16.6/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
/usr/local/bundle/gems/bundler-1.16.6/lib/bundler/cli.rb:27:in `dispatch'
/usr/local/bundle/gems/bundler-1.16.6/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
/usr/local/bundle/gems/bundler-1.16.6/lib/bundler/cli.rb:18:in `start'
/usr/local/bundle/gems/bundler-1.16.6/exe/bundle:30:in `block in <top (required)>'
/usr/local/bundle/gems/bundler-1.16.6/lib/bundler/friendly_errors.rb:124:in `with_friendly_errors'
/usr/local/bundle/gems/bundler-1.16.6/exe/bundle:22:in `<top (required)>'
/usr/local/bundle/bin/bundle:104:in `load'
/usr/local/bundle/bin/bundle:104:in `<main>'
Tasks: TOP => db:setup => db:schema:load_if_ruby => environment
(See full trace by running task with --trace)
我使用的是docker ruby映像版本2.3.1。
我试过了:schema:load,尝试删除数据库,再次创建,运行迁移,但始终出现相同的错误。
知道为什么会这样吗?
暂无答案!
目前还没有任何答案,快来回答吧!