Permalink
Browse files

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>
  • Loading branch information...
1 parent 973c0ef commit 00d2165f748bc3d7c235daa959c54266a0a283db @tarmo tarmo committed with jeremy Aug 26, 2008
Showing with 6 additions and 5 deletions.
  1. +6 −5 activerecord/lib/active_record/migration.rb
View
11 activerecord/lib/active_record/migration.rb
@@ -406,12 +406,14 @@ def schema_migrations_table_name
Base.table_name_prefix + 'schema_migrations' + Base.table_name_suffix
end
+ def get_all_versions
+ Base.connection.select_values("SELECT version FROM #{schema_migrations_table_name}").map(&:to_i).sort
+ end
+
def current_version
sm_table = schema_migrations_table_name
if Base.connection.table_exists?(sm_table)
- Base.connection.select_value(
- "SELECT MAX(CAST(version AS DECIMAL)) FROM #{sm_table}"
- ).to_i
+ get_all_versions.max || 0
else
0
end
@@ -521,8 +523,7 @@ def pending_migrations
end
def migrated
- sm_table = self.class.schema_migrations_table_name
- @migrated_versions ||= Base.connection.select_values("SELECT version FROM #{sm_table}").map(&:to_i).sort
+ @migrated_versions ||= self.class.get_all_versions
end
private

0 comments on commit 00d2165

Please sign in to comment.