-
Notifications
You must be signed in to change notification settings - Fork 21.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed rails dbconsole to support DATABASE_URL #13328
Conversation
Awesome @teohm! Could you add a changelog entry please ? |
ActiveRecord::ConnectionAdapters::ConnectionSpecification::Resolver.new( | ||
ENV['DATABASE_URL'], | ||
Rails.application.config.database_configuration.to_h | ||
).spec.config.to_h.stringify_keys |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think to_h
is only available with Ruby 2.0+ so this is the reason why the build fail with 1.9.3 on Travis.
@robin850 One more minor thing I wish to discuss. Currently I let all errors raised in But I'm looking for a 2nd opinion, what do you think? |
@teohm passing exceptions through is 👍 |
|
||
app_db_file("test:\n without_init") | ||
assert_equal Rails::DBConsole.new.config, "without_init" | ||
Rails::DBConsole.const_set('APP_PATH', 'rails/all') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will leak outside of this test case. Can you define it in setup
and remove it in teardown
?
@teohm added a few minor comments. Let me know when you updated. |
@senny, thanks for your code review! I have updated the commits:
|
@teohm 👍 can you squash your commits? |
@senny squashed. |
Fixed rails dbconsole to support DATABASE_URL
@teohm thank you for your contribution 💛 |
@senny thanks for the merge! 🍻 |
Fixed rails dbconsole to support DATABASE_URL Conflicts: railties/CHANGELOG.md
This looks great ❤️ thanks for the work here 😄 |
Awesome guys! 🍰 (sorry for the late reply though @teohm) |
Fixes #13320.
Problem
rails dbconsole
raises error whenENV['DATABASE_URL']
exists andconfig/database.yml
removed (see /issues/13320).Solution
ActiveRecord and
rake db:*
usesConnectionSpecification::Resolver
to loads DATABASE_URL properly. This patch modifiesrails dbconsole
to use the same class.