環境
Winodows 1p Pro (64bit)
Vagrant 2.2.14
Ubuntu 16.04.6 LTS
Docker 18.09.7
ruby:ruby 2.7.2p137
Herokuへリリースしてからデーターベースのマイグレーションの処理をしました。
sudo heroku run bundle exec rake db:migrate RAILS_ENV=production -a アプリ名
しかし以下のエラーが発生しました。
ActiveRecord::DatabaseConfigurations::InvalidConfigurationError: '{ host => }' is not a valid configuration. Expected '' to be a URL string or a Hash. /usr/local/bundle/gems/activerecord-6.1.1/lib/active_record/database_configurations.rb:223:in `build_db_config_from_raw_config' /usr/local/bundle/gems/activerecord-6.1.1/lib/active_record/database_configurations.rb:172:in `block in build_configs' /usr/local/bundle/gems/activerecord-6.1.1/lib/active_record/database_configurations.rb:168:in `each' /usr/local/bundle/gems/activerecord-6.1.1/lib/active_record/database_configurations.rb:168:in `flat_map' /usr/local/bundle/gems/activerecord-6.1.1/lib/active_record/database_configurations.rb:168:in `build_configs' /usr/local/bundle/gems/activerecord-6.1.1/lib/active_record/database_configurations.rb:19:in `initialize' /usr/local/bundle/gems/activerecord-6.1.1/lib/active_record/tasks/database_tasks.rb:168:in `new' /usr/local/bundle/gems/activerecord-6.1.1/lib/active_record/tasks/database_tasks.rb:168:in `for_each' /usr/local/bundle/gems/activerecord-6.1.1/lib/active_record/railties/databases.rake:34:in `block (2 levels) in <main>' /usr/local/bundle/gems/activerecord-6.1.1/lib/active_record/railties/databases.rake:29:in `block in <main>' /usr/local/bundle/gems/activerecord-6.1.1/lib/active_record/railties/databases.rake:9:in `<main>' /usr/local/bundle/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:77:in `load' /usr/local/bundle/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:77:in `load' /usr/local/bundle/gems/activesupport-6.1.1/lib/active_support/dependencies.rb:326:in `block in load' /usr/local/bundle/gems/activesupport-6.1.1/lib/active_support/dependencies.rb:299:in `load_dependency' /usr/local/bundle/gems/activesupport-6.1.1/lib/active_support/dependencies.rb:326:in `load' /usr/local/bundle/gems/activerecord-6.1.1/lib/active_record/railtie.rb:49:in `block in <class:Railtie>' /usr/local/bundle/gems/railties-6.1.1/lib/rails/railtie.rb:263:in `instance_exec' /usr/local/bundle/gems/railties-6.1.1/lib/rails/railtie.rb:263:in `block in run_tasks_blocks' /usr/local/bundle/gems/railties-6.1.1/lib/rails/railtie.rb:275:in `each' /usr/local/bundle/gems/railties-6.1.1/lib/rails/railtie.rb:275:in `each_registered_block' /usr/local/bundle/gems/railties-6.1.1/lib/rails/railtie.rb:263:in `run_tasks_blocks' /usr/local/bundle/gems/railties-6.1.1/lib/rails/application.rb:520:in `block in run_tasks_blocks' /usr/local/bundle/gems/railties-6.1.1/lib/rails/engine/railties.rb:15:in `each' /usr/local/bundle/gems/railties-6.1.1/lib/rails/engine/railties.rb:15:in `each' /usr/local/bundle/gems/railties-6.1.1/lib/rails/application.rb:520:in `run_tasks_blocks' /usr/local/bundle/gems/railties-6.1.1/lib/rails/engine.rb:464:in `load_tasks' /app/Rakefile:6:in `<top (required)>' /usr/local/bundle/gems/rake-13.0.3/exe/rake:27:in `<top (required)>' /usr/local/bin/bundle:23:in `load' /usr/local/bin/bundle:23:in `<main>' (See full trace by running task with --trace)
似たよな症状の情報を参照しました。
Rails5.2.3から6.0.2へのアップグレード後に起動できない
database.ymlを怪しんでいますが、何がおかしいのか分かりません。
{host}がおかしいとか言っていますが・・。
database.yml
# MySQL. Versions 5.5.8 and up are supported. # # Install the MySQL driver # gem install mysql2 # # Ensure the MySQL gem is defined in your Gemfile # gem 'mysql2' # # And be sure to use new-style password hashing: # https://dev.mysql.com/doc/refman/5.7/en/password-hashing.html # default: &default adapter: mysql2 encoding: utf8mb4 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> username: root password: password host: db development: <<: *default database: app_development # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: <<: *default database: app_test # As with config/credentials.yml, you never want to store sensitive information, # like your database password, in your source code. If your source code is # ever seen by anyone, they now have access to your database. # # Instead, provide the password or a full connection URL as an environment # variable when you boot the app. For example: # # DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase" # # If the connection URL is provided in the special DATABASE_URL environment # variable, Rails will automatically merge its configuration values on top of # the values provided in this file. Alternatively, you can specify a connection # URL environment variable explicitly: # # production: # url: <%= ENV['MY_APP_DATABASE_URL'] %> # # Read https://guides.rubyonrails.org/configuring.html#configuring-a-database # for a full overview on how database connection configuration can be specified. production: <<: *default database: <%= ENV['APP_DATABASE'] %> username: <%= ENV['APP_DATABASE_USERNAME'] %> password: <%= ENV['APP_DATABASE_PASSWORD'] %> host: <%= ENV['APP_DATABASE_HOST'] %>
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/01/31 12:54