diff options
author | Tarmo Tänav <tarmo@itech.ee> | 2008-08-26 09:14:12 +0300 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-08-25 23:23:34 -0700 |
commit | 77b003fb615a1a0b197af9fbb9066622bf489b57 (patch) | |
tree | bdef1e65031ff67d7d83147fdd95c69d54932e37 | |
parent | 3d2ac918b987ef0cff34f6a7fdd20926b7a9e5d9 (diff) | |
download | rails-77b003fb615a1a0b197af9fbb9066622bf489b57.tar.gz rails-77b003fb615a1a0b197af9fbb9066622bf489b57.tar.bz2 rails-77b003fb615a1a0b197af9fbb9066622bf489b57.zip |
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>
-rw-r--r-- | activerecord/lib/active_record/migration.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index 7a1fd7cfbc..6d101e9db5 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -407,9 +407,14 @@ module ActiveRecord end def current_version - Base.connection.select_value( - "SELECT MAX(CAST(version AS integer)) FROM #{schema_migrations_table_name}" - ).to_i rescue 0 + 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 + else + 0 + end end def proper_table_name(name) |