about summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorOndřej Hruška <ondra@ondrovo.com>2017-10-11 21:27:17 +0200
committerOndřej Hruška <ondra@ondrovo.com>2017-10-11 21:27:17 +0200
commit0bf9261e65b08cb54f43303c20d693649e16c079 (patch)
treecfb53d634da666fbc75b3854199fd44201085bf9 /lib
parent3cc6255a7e01645799be7af01de0d7c2ec18832a (diff)
parent6bc07d3de37f8bcfdd3324eb5aca05bee0e8d19c (diff)
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'lib')
-rw-r--r--lib/mastodon/migration_helpers.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/mastodon/migration_helpers.rb b/lib/mastodon/migration_helpers.rb
index ed716501e..80a8f440c 100644
--- a/lib/mastodon/migration_helpers.rb
+++ b/lib/mastodon/migration_helpers.rb
@@ -335,7 +335,10 @@ module Mastodon
 
       start_arel = table.project(table[:id]).order(table[:id].asc).take(1)
       start_arel = yield table, start_arel if block_given?
-      start_id = exec_query(start_arel.to_sql).to_hash.first['id'].to_i
+      first_row = exec_query(start_arel.to_sql).to_hash.first
+      # In case there are no rows but we didn't catch it in the estimated size:
+      return unless first_row
+      start_id = first_row['id'].to_i
       
       say "Migrating #{table_name}.#{column} (~#{total.to_i} rows)"