diff --git a/lib/travis/model/build.rb b/lib/travis/model/build.rb
index <HASH>..<HASH> 100644
--- a/lib/travis/model/build.rb
+++ b/lib/travis/model/build.rb
@@ -76,7 +76,11 @@ class Build < ActiveRecord::Base
     end
 
     def on_branch(branch)
-      pushes.where(branch.present? ? ['branch IN (?)', normalize_to_array(branch)] : [])
+      if Build.column_names.include?('branch')
+        pushes.where(branch.present? ? ['branch IN (?)', normalize_to_array(branch)] : [])
+      else
+        pushes.joins(:commit).where(branch.present? ? ['commits.branch IN (?)', normalize_to_array(branch)] : [])
+      end
     end
 
     def by_event_type(event_type)
Make on_branch method backwards compatible