Read database.yml from inside ActiveRecord migration

How to access content database.ymlinside ActiveRecord migration? In particular, I need a key value databasefor the migrated database.

+3
source share
2 answers
db = YAML.load_file("#{RAILS_ROOT}/config/database.yml")[RAILS_ENV]['database']
+7
source

Try ActiveRecord::Base.configurations

+3
source

Source: https://habr.com/ru/post/1761136/


All Articles