-
Notifications
You must be signed in to change notification settings - Fork 504
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
Cannot run rake task db:create
with mysql.
#426
Comments
I am running into a similar issue with |
My current workaround:
|
@jughead thanks for the workaround. Didn't you mean to invoke This works better for me, otherwise chaining |
The problem with this approach is that passing in tasks to the arguments of the I was able to get this to work more consistently with this:
Where there's a task |
Thank you @evanboho Can you share your |
Hello all, is there any update on this issue? thanks :) |
There is simpler solution. You can put
in Rakefile and it will do the trick. |
Hey guys! There seems to be an interesting issue related to
db:create
rake tasks that were failing. This is a synopsis of our research (thanks @camertron):Issue:
When running
bundle exec rake db:create
rake task on a fresh rails server, using mysql2 adapters, we get the following error:What seems to be the issue here is that we are calling the create task: here.
The
connection
is anOctopus::Proxy
class which when calling thecreate_database
method, hitsOctopus::Proxy#method_missing
which eventually delegates to: safe_connection's connectionThe problem here is two things:
Rails
db:create
rake task establishes the connection with a database configuration{ 'database' => nil }
: hereThe Octopus is overriding this connection with
connection_pool.connection
which uses a database configuration{ 'database' => value in yaml file}
. This connection raises theUnknown database
issue.Proposed solution:
Alias the
establish_connection
method to explicitly and return anestablish_connection_without_octopus
connection.This will cause
establish_connection configuration_without_database
to return aMySQL2::Adapter
class instead of aOctopus::Proxy
class, from which we can successfully callconnection.create_database
and bypassOctopus::Proxy#method_missing
Replication stack of issue:
Gemfile:
Database.yml:
Shards.yml:
The text was updated successfully, but these errors were encountered: