public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Use DECIMAL instead of INTEGER when casting as mysql doesn't work with just 
"INTEGER" and other databases don't like "UNSIGNED" which mysql requires

And don't mask exceptions.

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Tarmo Tänav (author)
Mon Aug 25 23:14:12 -0700 2008
jeremy (committer)
Mon Aug 25 23:23:34 -0700 2008
commit  77b003fb615a1a0b197af9fbb9066622bf489b57
tree    bdef1e65031ff67d7d83147fdd95c69d54932e37
parent  3d2ac918b987ef0cff34f6a7fdd20926b7a9e5d9
...
407
408
409
410
411
412
 
 
 
 
 
 
 
 
413
414
415
...
407
408
409
 
 
 
410
411
412
413
414
415
416
417
418
419
420
0
@@ -407,9 +407,14 @@ module ActiveRecord
0
       end
0
 
0
       def current_version
0
-        Base.connection.select_value(
0
-          "SELECT MAX(CAST(version AS integer)) FROM #{schema_migrations_table_name}"
0
-        ).to_i rescue 0
0
+        sm_table = schema_migrations_table_name
0
+        if Base.connection.table_exists?(sm_table)
0
+          Base.connection.select_value(
0
+            "SELECT MAX(CAST(version AS DECIMAL)) FROM #{sm_table}"
0
+          ).to_i
0
+        else
0
+          0
0
+        end
0
       end
0
 
0
       def proper_table_name(name)

Comments