diff --git a/spec/lib/gitlab/database/migration_helpers_spec.rb b/spec/lib/gitlab/database/migration_helpers_spec.rb
index 9096ad101b0ba677a28282b85a8544c52e1553eb..4ec3f19e03fb55bb2c3714718d8df5e4976e0c35 100644
--- a/spec/lib/gitlab/database/migration_helpers_spec.rb
+++ b/spec/lib/gitlab/database/migration_helpers_spec.rb
@@ -13,6 +13,10 @@ describe Gitlab::Database::MigrationHelpers, lib: true do
     context 'outside a transaction' do
       before do
         expect(model).to receive(:transaction_open?).and_return(false)
+
+        unless Gitlab::Database.postgresql?
+          allow_any_instance_of(Gitlab::Database::MigrationHelpers).to receive(:disable_statement_timeout)
+        end
       end
 
       context 'using PostgreSQL' do