diff options
author | Tarmo Tänav <tarmo@itech.ee> | 2008-08-26 12:57:33 +0300 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-08-26 03:00:36 -0700 |
commit | 00d2165f748bc3d7c235daa959c54266a0a283db (patch) | |
tree | 449e11b2b8669c20807917fade197da0ef20ae76 /activerecord | |
parent | 973c0ef26d94b5cf2bd29dce177357d5905be211 (diff) | |
download | rails-00d2165f748bc3d7c235daa959c54266a0a283db.tar.gz rails-00d2165f748bc3d7c235daa959c54266a0a283db.tar.bz2 rails-00d2165f748bc3d7c235daa959c54266a0a283db.zip |
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>
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/migration.rb | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index 6d101e9db5..1d843fff28 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -406,12 +406,14 @@ module ActiveRecord 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 @@ module ActiveRecord 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 |