]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-1990 ORA-01795 when deleting orphan snapshots
authorsimonbrandhof <simon.brandhof@gmail.com>
Wed, 17 Nov 2010 15:23:59 +0000 (15:23 +0000)
committersimonbrandhof <simon.brandhof@gmail.com>
Wed, 17 Nov 2010 15:23:59 +0000 (15:23 +0000)
sonar-server/src/main/webapp/WEB-INF/db/migrate/152_delete_duplicated_lib_snapshots.rb

index 640ab06f4f58edff76d40724237324e97a50bb8e..c6c747532cda1dfa4338b4ad2e240b60e610a1fb 100644 (file)
@@ -47,7 +47,14 @@ class DeleteDuplicatedLibSnapshots < ActiveRecord::Migration
   def self.delete_snapshots(snapshots)
    if snapshots.size > 0
      say_with_time "Deleting #{snapshots.size} orphan snapshots..." do
-       Snapshot.delete(snapshots.map{|s| s.id})
+       sids=snapshots.map{|s| s.id}
+       page_size=950
+       page_count=(sids.size/page_size)
+       page_count+=1 if (sids.size % page_size)>0
+       page_count.times do |page_index|
+         page_sids=sids[page_index*page_size...(page_index+1)*page_size]
+         Snapshot.delete(page_sids)
+       end
      end
    end
   end