public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Back to fetching all versions in ruby instead of letting SQL do it as it's 
difficult to get all databases to convert the text value to a number with the 
same SQL

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Tarmo Tänav (author)
Tue Aug 26 02:57:33 -0700 2008
jeremy (committer)
Tue Aug 26 03:00:36 -0700 2008
commit  00d2165f748bc3d7c235daa959c54266a0a283db
tree    449e11b2b8669c20807917fade197da0ef20ae76
parent  973c0ef26d94b5cf2bd29dce177357d5905be211
...
406
407
408
 
 
 
 
409
410
411
412
413
414
 
415
416
417
...
521
522
523
524
525
 
526
527
528
...
406
407
408
409
410
411
412
413
414
415
 
 
 
416
417
418
419
...
523
524
525
 
 
526
527
528
529
0
@@ -406,12 +406,14 @@ module ActiveRecord
0
         Base.table_name_prefix + 'schema_migrations' + Base.table_name_suffix
0
       end
0
 
0
+      def get_all_versions
0
+        Base.connection.select_values("SELECT version FROM #{schema_migrations_table_name}").map(&:to_i).sort
0
+      end
0
+
0
       def current_version
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
+          get_all_versions.max || 0
0
         else
0
           0
0
         end
0
@@ -521,8 +523,7 @@ module ActiveRecord
0
     end
0
 
0
     def migrated
0
-      sm_table = self.class.schema_migrations_table_name
0
-      @migrated_versions ||= Base.connection.select_values("SELECT version FROM #{sm_table}").map(&:to_i).sort
0
+      @migrated_versions ||= self.class.get_all_versions
0
     end
0
 
0
     private

Comments