Browse files

Use DECIMAL instead of INTEGER when casting as mysql doesn't work wit…

…h 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>
  • Loading branch information...
1 parent 3d2ac91 commit 77b003fb615a1a0b197af9fbb9066622bf489b57 @tarmo tarmo committed with jeremy Aug 26, 2008
Showing with 8 additions and 3 deletions.
  1. +8 −3 activerecord/lib/active_record/migration.rb
View
11 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)

0 comments on commit 77b003f

Please sign in to comment.