aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/tasks
diff options
context:
space:
mode:
authorbogdanvlviv <bogdanvlviv@gmail.com>2017-08-26 00:06:10 +0300
committerbogdanvlviv <bogdanvlviv@gmail.com>2017-10-30 20:10:09 +0000
commita37d03c4b08451765acc721b51a4b5b7eab7e8cc (patch)
treed213a76d1cc0ea9b87395c4cb32c750014325a66 /activerecord/lib/active_record/tasks
parentc4867b88f6eed16230a90077b82ad02293ea45b3 (diff)
downloadrails-a37d03c4b08451765acc721b51a4b5b7eab7e8cc.tar.gz
rails-a37d03c4b08451765acc721b51a4b5b7eab7e8cc.tar.bz2
rails-a37d03c4b08451765acc721b51a4b5b7eab7e8cc.zip
Simplify implementation of `MySQLDatabaseTasks`
Don't process MySQL ERROR 1045, raise error instead Make behavior of `MySQLDatabaseTasks` more consistent with behavior of `PostgreSQLDatabaseTasks`
Diffstat (limited to 'activerecord/lib/active_record/tasks')
-rw-r--r--activerecord/lib/active_record/tasks/mysql_database_tasks.rb45
1 files changed, 0 insertions, 45 deletions
diff --git a/activerecord/lib/active_record/tasks/mysql_database_tasks.rb b/activerecord/lib/active_record/tasks/mysql_database_tasks.rb
index d6a46f7743..e697fa6def 100644
--- a/activerecord/lib/active_record/tasks/mysql_database_tasks.rb
+++ b/activerecord/lib/active_record/tasks/mysql_database_tasks.rb
@@ -3,8 +3,6 @@
module ActiveRecord
module Tasks # :nodoc:
class MySQLDatabaseTasks # :nodoc:
- ACCESS_DENIED_ERROR = 1045
-
delegate :connection, :establish_connection, to: ActiveRecord::Base
def initialize(configuration)
@@ -21,18 +19,6 @@ module ActiveRecord
else
raise
end
- rescue error_class => error
- if error.respond_to?(:errno) && error.errno == ACCESS_DENIED_ERROR
- $stdout.print error.message
- establish_connection root_configuration_without_database
- connection.create_database configuration["database"], creation_options
- if configuration["username"] != "root"
- connection.execute grant_statement.gsub(/\s+/, " ").strip
- end
- establish_connection configuration
- else
- raise
- end
end
def drop
@@ -97,37 +83,6 @@ module ActiveRecord
end
end
- def error_class
- if configuration["adapter"].include?("jdbc")
- require "active_record/railties/jdbcmysql_error"
- ArJdbcMySQL::Error
- elsif defined?(Mysql2)
- Mysql2::Error
- else
- StandardError
- end
- end
-
- def grant_statement
- <<-SQL
-GRANT ALL PRIVILEGES ON `#{configuration['database']}`.*
- TO '#{configuration['username']}'@'localhost'
-IDENTIFIED BY '#{configuration['password']}' WITH GRANT OPTION;
- SQL
- end
-
- def root_configuration_without_database
- configuration_without_database.merge(
- "username" => "root",
- "password" => root_password
- )
- end
-
- def root_password
- $stdout.print "Please provide the root password for your MySQL installation\n>"
- $stdin.gets.strip
- end
-
def prepare_command_options
args = {
"host" => "--host",