GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
Running rails dbconsole takes:
But I just want to connect to database and I don't want to type database name, password, etc. But it takes so long ~ 3 sec. I've removed application initialization for it and it takes now:
Here is where the issue lies, you can't assume that the database configuration file is at config/database.yml.
Similarly, if there's erb in it, that expects a booted app.
Could try YAML.load(Rails.root.join('config/database.yml').read) and fall back to loading the full env if YAML parsing fails or the requested config isn't available.
@josevalim @jeremy I've added fallback when parsing fails. For simple database.yml without app loading the result is ~0.5s and other cases it is still about 3s on my machine.
Why is this being cached? It looks like it's called once (unless there is an exception).
@tenderlove you are right of course no need to cache, fixed and rebased
In general, you don't want to rescue Exception.
We can catch only Psych::SyntaxError, Errno::ENOENT am I right?
@josevalim Is it need? Or I can close it.
A bit fixed and rebased
I'm not sure about this PR and I haven't heard any conclusions. I'll fix tests added in one of previous commits if it will need.
@jeremy done, could you take a look?
Thanks @route! Could you squash to one commit?
More faster rails dbconsole
Merge pull request #5910 from route/rails-dbconsole
Fast path starts the database console without loading the full Rails env