@@ -15,10 +15,8 @@ class SetCharsetForMysql < ActiveRecord::Migration |
||
15 | 15 |
end |
16 | 16 |
|
17 | 17 |
def change |
18 |
- conn = ActiveRecord::Base.connection |
|
19 |
- |
|
20 | 18 |
# This is migration is for MySQL only. |
21 |
- return unless conn.is_a?(ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter) |
|
19 |
+ return unless mysql? |
|
22 | 20 |
|
23 | 21 |
reversible do |dir| |
24 | 22 |
dir.up do |
@@ -63,7 +61,7 @@ class SetCharsetForMysql < ActiveRecord::Migration |
||
63 | 61 |
execute 'ALTER TABLE %s CHARACTER SET utf8 COLLATE utf8_unicode_ci' % table_name |
64 | 62 |
} |
65 | 63 |
|
66 |
- execute 'ALTER DATABASE %s CHARACTER SET utf8 COLLATE utf8_unicode_ci' % conn.current_database |
|
64 |
+ execute 'ALTER DATABASE %s CHARACTER SET utf8 COLLATE utf8_unicode_ci' % connection.current_database |
|
67 | 65 |
end |
68 | 66 |
|
69 | 67 |
dir.down do |
@@ -71,4 +69,8 @@ class SetCharsetForMysql < ActiveRecord::Migration |
||
71 | 69 |
end |
72 | 70 |
end |
73 | 71 |
end |
72 |
+ |
|
73 |
+ def mysql? |
|
74 |
+ ActiveRecord::Base.connection.adapter_name =~ /mysql/i |
|
75 |
+ end |
|
74 | 76 |
end |