diff --git a/db/migrate/20160902122721_drop_gitorious_field_from_application_settings.rb b/db/migrate/20160902122721_drop_gitorious_field_from_application_settings.rb
index 5395d38ea8f2ee70db466c8fa63dfc7bcf473559..3342744ba93429ead54ae4ab6c1f776625a2031a 100644
--- a/db/migrate/20160902122721_drop_gitorious_field_from_application_settings.rb
+++ b/db/migrate/20160902122721_drop_gitorious_field_from_application_settings.rb
@@ -7,7 +7,11 @@ class DropGitoriousFieldFromApplicationSettings < ActiveRecord::Migration
   def up
     require 'yaml'
 
-    yaml = connection.execute('SELECT import_sources FROM application_settings;').values[0][0]
+    yaml =  if Gitlab::Database.postgresql?
+              connection.execute('SELECT import_sources FROM application_settings;').values[0][0]
+            else
+              connection.execute('SELECT import_sources FROM application_settings;').first[0]
+            end
     yaml = YAML.safe_load(yaml)
     yaml.delete 'gitorious'