From 82b4faf81218bbd8916ab559590db236c7f80e46 Mon Sep 17 00:00:00 2001 From: Ian White Date: Thu, 17 Apr 2008 13:43:47 -0500 Subject: Fix migrations when migrating to a specified version number with a fresh database [#1 state:resolved] Signed-off-by: Joshua Peek --- activerecord/lib/active_record/migration.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index 573c6a4f02..1d63bb2f84 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -364,8 +364,10 @@ module ActiveRecord end def current_version - Base.connection.select_values( - "SELECT version FROM #{schema_migrations_table_name}").map(&:to_i).max || 0 + version = Base.connection.select_values( + "SELECT version FROM #{schema_migrations_table_name}" + ).map(&:to_i).max rescue nil + version || 0 end def proper_table_name(name) -- cgit v1.2.3