File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
activerecord/lib/active_record/railties Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -61,12 +61,14 @@ namespace :db do
61
61
@charset = ENV [ 'CHARSET' ] || 'utf8'
62
62
@collation = ENV [ 'COLLATION' ] || 'utf8_unicode_ci'
63
63
creation_options = { :charset => ( config [ 'charset' ] || @charset ) , :collation => ( config [ 'collation' ] || @collation ) }
64
+ error_class = config [ 'adapter' ] == 'mysql2' ? Mysql2 ::Error : Mysql ::Error
65
+ access_denied_error = 1045
64
66
begin
65
67
ActiveRecord ::Base . establish_connection ( config . merge ( 'database' => nil ) )
66
68
ActiveRecord ::Base . connection . create_database ( config [ 'database' ] , creation_options )
67
69
ActiveRecord ::Base . establish_connection ( config )
68
- rescue Mysql :: Error => sqlerr
69
- if sqlerr . errno == Mysql :: Error :: ER_ACCESS_DENIED_ERROR
70
+ rescue error_class => sqlerr
71
+ if sqlerr . errno == access_denied_error
70
72
print "#{ sqlerr . error } . \n Please provide the root password for your mysql installation\n >"
71
73
root_password = $stdin. gets . strip
72
74
grant_statement = "GRANT ALL PRIVILEGES ON #{ config [ 'database' ] } .* " \
You can’t perform that action at this time.
0 commit comments