无法运行rake db:migrate或任何其他与数据库相关的操作

时间:2017-04-16 14:34:05

标签: postgresql ruby-on-rails-4 rails-migrations

下午好,

我们正在尝试将我们的应用程序升级到Rails 5.第一步是从Rails 3.2迁移到Rails 4(是的,我们有点落后)。但是,当我们尝试运行rake db:migrate

时,我们收到以下错误消息
docker-compose run --rm web bundle exec rake db:migrate --trace
[tunemygc] not enabled
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
rake aborted!
ArgumentError: wrong number of arguments (0 for 1)
/usr/local/bundle/gems/activesupport-4.0.13/lib/active_support/core_ext/kernel/reporting.rb:85:in `capture'
(eval):2:in `table_exists_with_silencer?'
/usr/local/bundle/gems/activerecord-4.0.13/lib/active_record/schema_migration.rb:20:in `create_table'
/usr/local/bundle/gems/activerecord-4.0.13/lib/active_record/connection_adapters/abstract/schema_statements.rb:641:in `initialize_schema_migrations_table'
/usr/local/bundle/gems/activerecord-4.0.13/lib/active_record/migration.rb:882:in `initialize'
/usr/local/bundle/gems/activerecord-4.0.13/lib/active_record/migration.rb:768:in `new'
/usr/local/bundle/gems/activerecord-4.0.13/lib/active_record/migration.rb:768:in `up'
/usr/local/bundle/gems/activerecord-4.0.13/lib/active_record/migration.rb:746:in `migrate'
/usr/local/bundle/gems/activerecord-4.0.13/lib/active_record/railties/databases.rake:42:in `block (2 levels) in <top (required)>'
/usr/local/bundle/gems/rake-12.0.0/lib/rake/task.rb:250:in `call'
/usr/local/bundle/gems/rake-12.0.0/lib/rake/task.rb:250:in `block in execute'
/usr/local/bundle/gems/rake-12.0.0/lib/rake/task.rb:250:in `each'
/usr/local/bundle/gems/rake-12.0.0/lib/rake/task.rb:250:in `execute'
/usr/local/bundle/gems/rake-12.0.0/lib/rake/task.rb:194:in `block in invoke_with_call_chain'
/usr/local/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/usr/local/bundle/gems/rake-12.0.0/lib/rake/task.rb:187:in `invoke_with_call_chain'
/usr/local/bundle/gems/rake-12.0.0/lib/rake/task.rb:180:in `invoke'
/usr/local/bundle/gems/rake-12.0.0/lib/rake/application.rb:152:in `invoke_task'
/usr/local/bundle/gems/rake-12.0.0/lib/rake/application.rb:108:in `block (2 levels) in top_level'
/usr/local/bundle/gems/rake-12.0.0/lib/rake/application.rb:108:in `each'
/usr/local/bundle/gems/rake-12.0.0/lib/rake/application.rb:108:in `block in top_level'
/usr/local/bundle/gems/rake-12.0.0/lib/rake/application.rb:117:in `run_with_threads'
/usr/local/bundle/gems/rake-12.0.0/lib/rake/application.rb:102:in `top_level'
/usr/local/bundle/gems/rake-12.0.0/lib/rake/application.rb:80:in `block in run'
/usr/local/bundle/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling'
/usr/local/bundle/gems/rake-12.0.0/lib/rake/application.rb:77:in `run'
/usr/local/bundle/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
/usr/local/bundle/bin/rake:17:in `load'
/usr/local/bundle/bin/rake:17:in `<top (required)>'
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/lib/bundler/cli/exec.rb:74:in `load'
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/lib/bundler/cli/exec.rb:74:in `kernel_load'
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/lib/bundler/cli/exec.rb:27:in `run'
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/lib/bundler/cli.rb:335:in `exec'
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/lib/bundler/cli.rb:20:in `dispatch'
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/lib/bundler/cli.rb:11:in `start'
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/exe/bundle:32:in `block in <top (required)>'
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors'
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/exe/bundle:24:in `<top (required)>'
/usr/local/bin/bundle:22:in `load'
/usr/local/bin/bundle:22:in `<main>'
Tasks: TOP => db:migrate

我们已经做了一些调查,但找不到其他人遇到这个问题的方法。我们正在使用postgres:最新的docker image与pg 0.20.0 gem

更新:

添加Gemfile以供参考

source 'http://rubygems.org'
ruby '2.2.7'

# Fitmo gems
#gem 'fitmo-core', git: "https://a7697bdc4b3d4d6a458bac5fba0f9af68a521eec:x-oauth-basic@github.com/fitmo/fitmo-core.git", require: 'fitmo'
#gem 'fitmo-core', git: "https://a7697bdc4b3d4d6a458bac5fba0f9af68a521eec:x-oauth-basic@github.com/fitmo/fitmo-core.git", require: 'fitmo', branch: 'staging'
gem 'fitmo-core', git: "https://a7697bdc4b3d4d6a458bac5fba0f9af68a521eec:x-oauth-basic@github.com/fitmo/fitmo-core.git", require: 'fitmo', branch: 'rails4'
#gem 'fitmo-core', path: '../fitmo-core', require: 'fitmo'

gem 'rails',                  '~> 4.0.0'
gem 'rack',                   '~> 1.5.2'
gem 'rack-timeout'
gem 'rack-cache'

# temp to be deleted after migration
gem 'protected_attributes'
gem 'rails-observers'
gem 'actionpack-page_caching'
gem 'actionpack-action_caching'
gem 'activerecord-deprecated_finders'


# Webserver
gem "puma"
gem "puma_worker_killer"

# Caching
gem 'memcachier',             '~> 0.0.2'
gem 'dalli',                  '2.7.0'
gem 'connection_pool'

# Monitoring
#gem 'newrelic_rpm'
#gem "skylight"
gem 'tunemygc'

# Database
gem 'pg',                     '~> 0.18.4'

# Rails plugins
gem 'i18n',                   '~> 0.6.11'                         #'~> 0.7.0'
gem 'lograge'

gem 'ice_cube',               '~> 0.13.3'

# User authentication
gem "devise",                 '3.5.1'                             #'~> 3.5.1'
gem 'oauth2',                 '~> 1.3.1'
gem 'omniauth',               '~> 1.4.2'
gem 'omniauth-oauth2',        '~> 1.4.0'
gem 'omniauth-facebook'
gem 'omniauth-jawbone',       '~> 1.0'                            #'~> 1.0'

# User authentication
gem 'oa-openid',              '~> 0.3.2', :require => 'omniauth/openid'

# pub/sub integration
gem 'pusher'

# Layer integration
gem 'layer-identity_token'
#gem 'layer-ruby',             require: 'layer', github: 'benedikt/layer-ruby'
#gem 'layer-ruby',             '~> 0.5.2'
gem 'layer-ruby',             '~> 0.6.0'
gem 'rest-client',            '~> 1.8.0'

# Tools
gem 'oj',                     '= 2.9.9'                           #'~> 2.12.12'
#gem 'rabl'
#gem 'rabl',                   git: 'https://github.com/dhiemstra/rabl.git', branch: 'cache_prefix'
gem 'rabl',                   git: 'https://a7697bdc4b3d4d6a458bac5fba0f9af68a521eec:x-oauth-basic@github.com/fitmo/rabl.git'
gem 'faraday'
gem 'chronic',                git: 'https://github.com/mojombo/chronic.git' #sorry mate

# Background jobs
gem 'resque',                 '~> 1.26.0'
gem 'resque_mailer',          '~> 2.3.1'
gem 'resque-scheduler',       '~> 4.3.0'
gem 'devise-async'#,           '~> 0.8.0'                          #'~> 0.10.1'

# Frontend
gem 'haml',                   '~> 4.0.3'                          #'~> 4.0.7'
gem 'haml-rails',             '~> 0.4'                            #'~> 0.9'
gem 'haml-contrib'
gem 'jquery-rails',           '~> 3.1.4'                             #'~> 4.0.4'
gem 'jquery-ui-rails',        '~> 5.0.5'
gem 'simple_form',            '= 3.2.0'                          #'~> 3.1.0'
gem 'modernizr-rails'
gem "rails-backbone",         '~> 1.2.0'    #'0.7.2'                             #'~> 1.2.0'

# Plugins
gem 'appsignal',              '~> 2.1.2'
gem 'geocoder',               '~> 1.1.5'                          #'~> 1.2.9'
gem 'timezone'
gem 'browser',                '~> 1.1.0'                          #'~> 2.2.0'
gem 'countries',              '~> 0.9.3'                          #'~> 0.11.5'
gem 'intercom-rails',         '~> 0.3.5'                            #'~> 0.2.28'

## Social and 3rd party vendors
gem "koala",                  '~> 2.4.0'
gem 'health_graph'#,           git: 'https://a7697bdc4b3d4d6a458bac5fba0f9af68a521eec:x-oauth-basic@github.com/fitmo/health_graph.git'
gem 'jawbone',                git: 'https://github.com/andrewpbrett/jawbone-up-api'
gem 'fitbit-api-client',      require: 'fitbit'
#gem 'fitbit-api-client',      git: 'https://a7697bdc4b3d4d6a458bac5fba0f9af68a521eec:x-oauth-basic@github.com/fitmo/fitbit-api-ruby-client.git', require: 'fitbit'
#gem 'fitbit-api-client',      path: '../fitbit-api-ruby-client', require: 'fitbit'

gem 'mailchimp-api',          '~> 2.0.4', require: nil
gem 'analytics-ruby',         '~> 2.0.12', require: 'segment/analytics' # segment
gem 'mandrill-api',           '~> 1.0.51'                         #'~> 1.0.53'
gem 'stripe',                 '~> 1.15.0'                         #'~> 1.24.0'
gem 'opentok',                '~> 0.1.2', require: nil            #'~> 2.3.3'
gem 'activemerchant',         '~> 1.64.0'                         #'~> 1.52.0'
gem 'activeuuid'

gem 'net-ssh',                '!= 2.10.0'

# Gems used only for assets and not required
# in production environments by default.

#removed :assets group as part of rails4 migration
gem 'sass-rails',           "~> 4.0.0"
gem 'bootstrap-sass',       '~> 3.0.2.1'
gem 'coffee-rails',         "~> 4.0.0"
gem 'uglifier',             '~> 2.2.1'
gem 'coffee-script',        '2.2.0'
gem 'compass-rails'
gem 'haml_coffee_assets',   '~> 1.12.0'
gem 'execjs' # needed for haml_coffee_assets

group :development do
  gem 'derailed'
end

group :test, :development do
  gem 'silent-postgres'
  gem 'dotenv-rails'
end

group :test do
  gem 'ruby-prof'
  gem 'test-unit'
  gem 'forgery'
  gem 'factory_girl_rails',     '~> 4.5.0'
  gem 'memcache-client'
  gem 'database_cleaner'                                    # 1.5.0
  gem "rspec",                  "~> 3.5.0"
  gem "rspec-rails",            "~> 3.5.0"
  gem "rspec-mocks",            "~> 3.5.0"
  gem "email_spec",             "~> 1.6.0", :require => nil
  gem 'capybara',               "~> 2.5.0"
  gem 'nokogiri',               '~> 1.6.1'                    # 1.6.6.2
  gem "selenium-webdriver",     "~> 2.37.0"                   # 2.47.1
  gem "poltergeist",            "~> 1.6.0"
  gem 'spork',                  '~> 0.9.2'
  gem 'caulfield'                                             # 0.0.10
  gem 'launchy'                                               # 2.4.3
  gem 'vcr',                    '~> 2.6.0'                    # 2.9.3
  gem 'resque_spec',            '~> 0.17.0'
  gem 'simplecov',              require: nil                  # 0.10.0
  gem 'mock_redis'                                            # 0.15.3
  gem 'timecop',                '~> 0.8.0'
  gem 'rspec_junit_formatter',  '~> 0.2.3'
end

fitmo-core gemspec文件

# encoding: utf-8

$:.unshift File.expand_path('../lib', __FILE__)
require 'fitmo_core/version'

Gem::Specification.new do |s|
  s.name         = "fitmo-core"
  s.version      = FitmoCore::VERSION
  s.authors      = ["Fitmo"]
  s.email        = "info@fitmo.com"
  s.homepage     = "https://github.com/fitmo/fitmo-core"
  s.summary      = "Fitmo models"

  #s.files        = Dir['{lib/**/*,spec/**/*,[A-Z]*}']
  #s.platform     = Gem::Platform::RUBY
  #s.require_path = 'lib'
  #s.rubyforge_project = '[none]'

  s.files         = `git ls-files`.split("\n")
  s.test_files    = `git ls-files -- {test,spec,features}/*`.split("\n")
  s.executables   = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
  s.require_paths = ["lib"]

  s.add_dependency 'rake'
  s.add_dependency 'actionmailer',                        '~> 4.0.0'
  s.add_dependency 'activerecord',                        '~> 4.0.0'
  s.add_dependency 'activesupport',                       '~> 4.0.0'
  s.add_dependency 'railties',                            '~> 4.0.0'

  # temp to be deleted after migration
  s.add_dependency 'protected_attributes'
  s.add_dependency 'rails-observers'
  s.add_dependency 'actionpack-page_caching'
  s.add_dependency 'actionpack-action_caching'
  s.add_dependency 'activerecord-deprecated_finders'

  # Model plugins
  s.add_dependency 'paranoia',                            '~> 2.2.1'
  s.add_dependency 'acts-as-taggable-on',                 '~> 4.0.0'

  # File uploads
  s.add_dependency 'carrierwave',                         '~> 1.0.0'
  s.add_dependency 'rmagick',                             '~> 2.13.1'
  s.add_dependency 'fog'#,                                 '~> 1.28.0'
  s.add_dependency 'unf',                                 '~> 0.1.3'
  s.add_dependency 'mime-types'#,                          '~> 1.25'

  # Others
  s.add_dependency 'rpush',                               '~> 2.7.0'
  s.add_dependency 'net-http-persistent',                 '~> 2.9.4'
  s.add_dependency 'countries',                           '~> 0.9.3'
  s.add_dependency 'alchemist',                           '~> 0.1.7'
  s.add_dependency 'rest-client',                         '~> 1.8.0'
  s.add_dependency 'nokogiri'#,                            '~> 1.6.0'

  s.add_dependency 'ice_cube',                            '~> 0.13.3'
  s.add_dependency 'pg',                                  '~> 0.18.4'
  s.add_dependency 'activeuuid'

  s.add_dependency 'appsignal',                           '~> 2.1.2'

  s.add_development_dependency 'rspec',                   '~> 3.5.0'
  s.add_development_dependency 'database_cleaner'
  s.add_development_dependency 'forgery'
  s.add_development_dependency 'factory_girl',            '~> 3.6.2'
  s.add_development_dependency 'vcr',                     '~> 2.3.0'
  s.add_development_dependency 'faraday',                 '~> 0.7.6'
  s.add_development_dependency 'timecop',                 '~> 0.7.3'
  s.add_development_dependency 'rspec_junit_formatter',   '~> 0.2.3'

  s.add_development_dependency 'micro_migrations'          #,        git: 'https://gist.github.com/2087829.git'

end

有什么想法吗?

感谢

1 个答案:

答案 0 :(得分:1)

问题是由于使用了不推荐使用的postgres-silent gem