From 77b003fb615a1a0b197af9fbb9066622bf489b57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20T=C3=A4nav?= Date: Tue, 26 Aug 2008 09:14:12 +0300 Subject: [PATCH] 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 --- activerecord/lib/active_record/migration.rb | 11 ++++++++--- 1 file 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 @@ def schema_migrations_table_name 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) -- GitLab