Heroku - Rails 6 - 多数据库
Heroku - Rails 6 - multi-database
rails: gem "rails", "6.0.0.rc2"
我有多个数据库。 None 是副本(我正在阅读和写作所有 3 个):
在 rails 6 之前,我使用了 multiverse gem 并且所有内容看起来 fine.I 都遵循 rails 6 并且 multiverse 更改为 rails 6 文档。但是我不能在 Heroku 中 运行 db:migrate,尽管一切都在本地完美运行。
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
establish_connection :primary
end
.
class ObsRecord < ActiveRecord::Base
self.abstract_class = true
establish_connection :obs
end
.
class AbcRecord < ActiveRecord::Base
self.abstract_class = true
establish_connection :abc
end
database.yml
staging:
primary:
<<: *default
adapter: postgresql
url: <%= ENV['DATABASE_URL'] %>
username: <%= ENV['DATABASE_USER'] %>
password: <%= ENV['DATABASE_PASSWORD'] %>
obs:
<<: *default
adapter: postgresql
url: <%= ENV['OBS_DATABASE_URL'] %>
username: <%= ENV['OBS_DATABASE_USER'] %>
password: <%= ENV['OBS_DATABASE_PASSWORD'] %>
migrations_paths: db/obs_migrate
abc:
<<: *default
adapter: postgresql
url: <%= ENV['ABC_DATABASE_URL'] %>
username: <%= ENV['ABC_DATABASE_USER'] %>
password: <%= ENV['ABC_DATABASE_PASSWORD'] %>
migrations_paths: db/abc_migrate
rails db:migrate
什么也没显示,就好像没有迁移一样,但是当我 运行 rails c
时,我看到以下错误。是的,我确定已推送最新代码。
heroku restart
没有帮助
Heroku 错误:
Traceback (most recent call last):
102: from /app/bin/rails:4:in `<main>'
101: from /app/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.0.rc2/lib/active_support/dependencies.rb:322:in `require'
.
.
4: from /app/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc2/lib/active_record/connection_handling.rb:50:in `establish_connection'
3: from /app/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc2/lib/active_record/connection_handling.rb:180:in `resolve_config_for_connection'
2: from /app/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc2/lib/active_record/connection_adapters/connection_specification.rb:140:in `resolve'
1: from /app/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc2/lib/active_record/connection_adapters/connection_specification.rb:219:in `resolve_connection'.
.
/app/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc2/lib/active_record/connection_adapters/connection_specification.rb:251:in `resolve_symbol_connection': The `abc` database is not configured for the `staging` environment. (ActiveRecord::AdapterNotSpecified)
Available databases configurations are:
default
prod_uat_default
development
test
staging
uat
production
^^ 我期待 primary、abc 和 obs 正在分期。
另外,rails -T
没有显示关于我的第二个和第三个数据库的任何信息
使用 6.0-stable 版本并且有效:
gem "rails", github: "rails/rails", branch: "6-0-stable"
rails: gem "rails", "6.0.0.rc2"
我有多个数据库。 None 是副本(我正在阅读和写作所有 3 个): 在 rails 6 之前,我使用了 multiverse gem 并且所有内容看起来 fine.I 都遵循 rails 6 并且 multiverse 更改为 rails 6 文档。但是我不能在 Heroku 中 运行 db:migrate,尽管一切都在本地完美运行。
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
establish_connection :primary
end
.
class ObsRecord < ActiveRecord::Base
self.abstract_class = true
establish_connection :obs
end
.
class AbcRecord < ActiveRecord::Base
self.abstract_class = true
establish_connection :abc
end
database.yml
staging:
primary:
<<: *default
adapter: postgresql
url: <%= ENV['DATABASE_URL'] %>
username: <%= ENV['DATABASE_USER'] %>
password: <%= ENV['DATABASE_PASSWORD'] %>
obs:
<<: *default
adapter: postgresql
url: <%= ENV['OBS_DATABASE_URL'] %>
username: <%= ENV['OBS_DATABASE_USER'] %>
password: <%= ENV['OBS_DATABASE_PASSWORD'] %>
migrations_paths: db/obs_migrate
abc:
<<: *default
adapter: postgresql
url: <%= ENV['ABC_DATABASE_URL'] %>
username: <%= ENV['ABC_DATABASE_USER'] %>
password: <%= ENV['ABC_DATABASE_PASSWORD'] %>
migrations_paths: db/abc_migrate
rails db:migrate
什么也没显示,就好像没有迁移一样,但是当我 运行 rails c
时,我看到以下错误。是的,我确定已推送最新代码。
heroku restart
没有帮助
Heroku 错误:
Traceback (most recent call last):
102: from /app/bin/rails:4:in `<main>'
101: from /app/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.0.rc2/lib/active_support/dependencies.rb:322:in `require'
.
.
4: from /app/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc2/lib/active_record/connection_handling.rb:50:in `establish_connection'
3: from /app/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc2/lib/active_record/connection_handling.rb:180:in `resolve_config_for_connection'
2: from /app/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc2/lib/active_record/connection_adapters/connection_specification.rb:140:in `resolve'
1: from /app/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc2/lib/active_record/connection_adapters/connection_specification.rb:219:in `resolve_connection'.
.
/app/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc2/lib/active_record/connection_adapters/connection_specification.rb:251:in `resolve_symbol_connection': The `abc` database is not configured for the `staging` environment. (ActiveRecord::AdapterNotSpecified)
Available databases configurations are:
default
prod_uat_default
development
test
staging
uat
production
^^ 我期待 primary、abc 和 obs 正在分期。
另外,rails -T
没有显示关于我的第二个和第三个数据库的任何信息
使用 6.0-stable 版本并且有效:
gem "rails", github: "rails/rails", branch: "6-0-stable"