作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我们正在从 5.2
升级我们的 rails 应用程序至 6.0.1
,现在每当我们运行 db:schema:load --trace
我们得到以下错误。
** Invoke db:schema:load (first_time)
** Invoke db:load_config (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:load_config
** Invoke db:check_protected_environments (first_time)
** Invoke db:load_config
** Execute db:check_protected_environments
** Invoke environment
** Execute db:schema:load
rake aborted!
NoMethodError: undefined method `spec' for #<ActiveRecord::ConnectionAdapters::NullPool:0x00007fa648b78a40>
Did you mean? inspect
/Users/Documents/vendor/ruby/2.6.0/gems/activerecord-6.0.1/lib/active_record/connection_adapters/abstract_adapter.rb:168:in `schema_migration'
/Users/Documents/vendor/ruby/2.6.0/gems/activerecord-6.0.1/lib/active_record/schema.rb:54:in `define'
/Users/Documents/vendor/ruby/2.6.0/gems/activerecord-6.0.1/lib/active_record/schema.rb:47:in `define'
/Users/Documents/db/schema.rb:13:in `<main>'
/Users/Documents/vendor/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `load'
/Users/Documents/vendor/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `load'
/Users/Documents/vendor/ruby/2.6.0/gems/activerecord-6.0.1/lib/active_record/tasks/database_tasks.rb:328:in `load_schema'
/Users/Documents/vendor/ruby/2.6.0/gems/activerecord-6.0.1/lib/active_record/tasks/database_tasks.rb:425:in `block in load_schema_current'
/Users/Documents/vendor/ruby/2.6.0/gems/activerecord-6.0.1/lib/active_record/tasks/database_tasks.rb:479:in `block (2 levels) in each_current_configuration'
/Users/Documents/vendor/ruby/2.6.0/gems/activerecord-6.0.1/lib/active_record/tasks/database_tasks.rb:476:in `each'
/Users/Documents/vendor/ruby/2.6.0/gems/activerecord-6.0.1/lib/active_record/tasks/database_tasks.rb:476:in `block in each_current_configuration'
/Users/Documents/vendor/ruby/2.6.0/gems/activerecord-6.0.1/lib/active_record/tasks/database_tasks.rb:475:in `each'
/Users/Documents/vendor/ruby/2.6.0/gems/activerecord-6.0.1/lib/active_record/tasks/database_tasks.rb:475:in `each_current_configuration'
/Users/Documents/vendor/ruby/2.6.0/gems/activerecord-6.0.1/lib/active_record/tasks/database_tasks.rb:424:in `load_schema_current'
/Users/Documents/vendor/ruby/2.6.0/gems/activerecord-6.0.1/lib/active_record/railties/databases.rake:397:in `block (3 levels) in <main>'
/Users/Documents/vendor/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `block in execute'
/Users/Documents/vendor/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `each'
/Users/Documents/vendor/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `execute'
/Users/Documents/vendor/ruby/2.6.0/gems/bugsnag-6.12.1/lib/bugsnag/integrations/rake.rb:19:in `execute'
/Users/Documents/vendor/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/Users/.asdf/installs/ruby/2.6.3/lib/ruby/2.6.0/monitor.rb:230:in `mon_synchronize'
/Users/Documents/vendor/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
/Users/Documents/vendor/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:188:in `invoke'
/Users/Documents/vendor/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:160:in `invoke_task'
/Users/Documents/vendor/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/Users/Documents/vendor/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `each'
/Users/Documents/vendor/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `block in top_level'
/Users/Documents/vendor/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:125:in `run_with_threads'
/Users/Documents/vendor/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:110:in `top_level'
/Users/Documents/vendor/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:83:in `block in run'
/Users/Documents/vendor/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/Documents/vendor/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:80:in `run'
/Users/Documents/vendor/ruby/2.6.0/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
/Users/Documents/vendor/ruby/2.6.0/bin/rake:23:in `load'
/Users/Documents/vendor/ruby/2.6.0/bin/rake:23:in `<top (required)>'
/Users/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/lib/bundler/cli/exec.rb:74:in `load'
/Users/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/lib/bundler/cli/exec.rb:74:in `kernel_load'
/Users/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/lib/bundler/cli/exec.rb:28:in `run'
/Users/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/lib/bundler/cli.rb:463:in `exec'
/Users/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/Users/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/Users/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
/Users/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/lib/bundler/cli.rb:27:in `dispatch'
/Users/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
/Users/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/lib/bundler/cli.rb:18:in `start'
/Users/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/exe/bundle:30:in `block in <top (required)>'
/Users/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/lib/bundler/friendly_errors.rb:124:in `with_friendly_errors'
/Users/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/exe/bundle:22:in `<top (required)>'
/Users/.asdf/installs/ruby/2.6.3/bin/bundle:23:in `load'
/Users/.asdf/installs/ruby/2.6.3/bin/bundle:23:in `<main>'
source 'https://rubygems.org'
ruby '~> 2.6.3'
gem 'rails', '6.0.1'
gem 'active_model_serializers', '~> 0.10.10'
gem 'activeadmin', '~> 2.5'
gem 'active_admin_datetimepicker', '~> 0.7'
gem 'active_elastic_job', '~> 2.0'
gem 'analytics-ruby', '~> 2.2', require: 'segment'
gem 'aws-sdk', '~> 2.1'
gem 'bootsnap', '>= 1.4.5', require: false
gem 'bugsnag', '~> 6.12'
gem 'cancancan', '~> 3.0'
gem 'combine_pdf', '~> 1.0'
gem 'crawler_detect', '~> 0.1'
gem 'devise', '~> 4.7'
gem 'ddtrace', '~> 0.22'
gem 'embedly', '~> 1.9'
gem 'emoji_data', '~> 0.2'
gem 'ey_config', '~> 0.0.7'
gem 'fast_jsonapi', '~> 1.4'
gem 'geocoder', '~> 1.5'
gem 'httparty', '~> 0.17'
gem 'jwplayer-api-client', '~> 0.1.0'
gem 'jwt', '~> 2.1'
gem 'lograge', '~> 0.11'
gem 'mini_magick', '~> 4.9'
gem 'mysql2', '~> 0.5'
gem 'mysql_online_migrations', '~> 1.0'
gem 'paperclip', '~> 5.3'
gem 'paranoia', '~> 2.4'
gem 'prawn', '~> 2.2'
gem 'puma', '3.12'
gem 'rack-attack', '~> 6.0'
gem 'rack-cors', '~> 1.0', require: 'rack/cors'
gem 'rack-rewrite', '~> 1.5'
gem 'rails-observers', '~> 0.1.5'
# This version needs to stay the same
gem 'redis', '3.3.5'
# This version needs to stay the same
gem 'redis-objects', '1.3'
gem 'redis-rails', '~> 5.0'
gem 'responders', '~> 3.0'
gem 'roboto', '~> 1.0.0'
gem 'ruby-hmac', '~> 0.4'
gem 'ruby-progressbar', '~> 1.10'
gem 'sendgrid-ruby', '~> 1.1'
gem 'stringex', '~> 2.8'
gem 'stripe', '~> 2.12'
gem 'uservoice-ruby', '~> 0.0.11'
gem 'versionist', '~> 1.7'
gem 'will_paginate', '~> 3.1'
# Assets
gem 'autoprefixer-rails', '~> 6.7'
gem 'bourbon', '~> 3.2.4'
gem 'coffee-rails', '~> 5.0'
gem 'neat', '~> 1.9.0'
gem 'sass-rails', '~> 6.0'
gem 'uglifier', '>= 1.3.0'
group :development, :test do
gem 'awesome_print'
gem 'brakeman'
gem 'bullet'
gem 'factory_bot_rails'
gem 'fasterer'
gem 'figaro'
gem 'fuubar'
gem 'guard-rspec', require: false
gem 'guard-rubocop'
gem 'pry-rails'
gem 'rails_best_practices'
gem 'rb-fsevent'
gem 'reek'
gem 'rspec-rails', '4.0.0.beta3'
gem 'spring'
gem 'spring-commands-rspec'
end
group :test do
gem 'rails-controller-testing'
gem 'semaphore_test_boosters'
gem 'shoulda-matchers', '~> 3.1'
gem 'simplecov', require: false
gem 'timecop'
gem 'webmock'
end
defaults: &defaults
adapter: mysql2
encoding: utf8
host: <%= ENV['RDS_HOSTNAME'] %>
username: <%= ENV['RDS_USERNAME'] %>
password: <%= ENV['RDS_PASSWORD'] %>
port: <%= ENV.fetch('RDS_PORT', 3306) %>
pool: <%= ENV.fetch('RDS_POOL', 5) %>
development:
primary:
<<: *defaults
database: <%= ENV['RDS_DATABASE'] %>
archive:
<<: *defaults
database: <%= ENV['RDS_ARCHIVE_DATABASE'] %>
migrations_paths: db/archive_migrate
archive_read_only:
<<: *defaults
host: <%= ENV['RDS_RO_HOSTNAME'] %>
database: <%= ENV['RDS_ARCHIVE_DATABASE'] %>
replica: true
production:
primary:
<<: *defaults
database: <%= ENV['RDS_DATABASE'] %>
archive:
<<: *defaults
database: <%= ENV['RDS_ARCHIVE_DATABASE'] %>
migrations_paths: db/archive_migrate
archive_read_only:
<<: *defaults
host: <%= ENV['RDS_RO_HOSTNAME'] %>
database: <%= ENV['RDS_ARCHIVE_DATABASE'] %>
replica: true
read_only:
<<: *defaults
host: <%= ENV['RDS_PROD_RO_HOSTNAME'] %>
database: <%= ENV['RDS_PROD_DATABASE'] %>
username: <%= ENV['RDS_PROD_USERNAME'] %>
password: <%= ENV['RDS_PROD_PASSWORD'] %>
test:
primary:
<<: *defaults
database: <%= ENV['RDS_DATABASE'] %>
archive:
<<: *defaults
database: <%= ENV['RDS_ARCHIVE_DATABASE'] %>
migrations_paths: db/archive_migrate
archive_read_only:
<<: *defaults
database: <%= ENV['RDS_ARCHIVE_DATABASE'] %>
replica: true
active_record
gem 和 put binding.pry
在多个地方看看发生了什么。 figaro
的用法 gem 在 database.yml
文件 config.active_record.schema_format = :sql
解决了这个问题。并通过使用
db:structure:load
创建
.sql
文件而不是
schema.rb
文件,但我们宁愿不必这样做。
最佳答案
通过提交 issue 得到了答案到 rails 。原来这是 mysql_online_migrations
的问题 gem 。
关于ruby-on-rails - 未定义的方法 `spec' #<ActiveRecord::ConnectionAdapters::NullPool:0x00007fd44f8ab300> - Rails 6 schema:load,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59339798/
我有 Zope/Plone 4.3 环境,我们使用 z3c.saconfig 在内部产品中配置数据库 (Oracle) 设置。 我需要将常用的 SQLAlchemy 池类型从 QueuePool 更改
我们正在从 5.2 升级我们的 rails 应用程序至 6.0.1 ,现在每当我们运行 db:schema:load --trace我们得到以下错误。 ** Invoke db:schema:load
我是一名优秀的程序员,十分优秀!