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>
This commit is contained in:
Tarmo Tänav 2008-08-26 09:14:12 +03:00 committed by Jeremy Kemper
parent 3d2ac918b9
commit 77b003fb61
1 changed files with 8 additions and 3 deletions

View File

@ -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)