]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4608 Migration issue on Oracle -> trying to insert some rows with some primary...
authorSimon Brandhof <simon.brandhof@gmail.com>
Mon, 2 Sep 2013 13:32:48 +0000 (15:32 +0200)
committerSimon Brandhof <simon.brandhof@gmail.com>
Mon, 2 Sep 2013 13:32:48 +0000 (15:32 +0200)
sonar-server/src/main/webapp/WEB-INF/db/migrate/287_index_projects.rb
sonar-server/src/main/webapp/WEB-INF/db/migrate/410_add_oracle_id_triggers.rb

index b972594686a7ac2a2c5be832ee33494e1385d0e3..38020bd4e5fac8b3f3948ae01923b8128a32beae 100644 (file)
@@ -22,6 +22,7 @@
 # Sonar 3.0
 #
 class IndexProjects < ActiveRecord::Migration
+
   class ResourceIndex < ActiveRecord::Base
     set_table_name 'resource_index'
   end
@@ -35,10 +36,19 @@ class IndexProjects < ActiveRecord::Migration
 
     projects = Project.find(:all, :select => 'id', :conditions => {:enabled => true, :scope => 'PRJ'})
 
-    say_with_time "Index #{projects.size} projects" do
-      projects.each do |project|
-        Java::OrgSonarServerUi::JRubyFacade.getInstance().indexResource(project.id)
+    if projects.size>0
+      if dialect()=='oracle'
+        # SONAR-4608
+        # Fix upgrade from 2.x to 3.7
+        create_id_trigger('resource_index')
+      end
+
+      say_with_time "Index #{projects.size} projects" do
+        projects.each do |project|
+          Java::OrgSonarServerUi::JRubyFacade.getInstance().indexResource(project.id)
+        end
       end
     end
   end
+
 end
index 713edd7d93080e1e0ff863c17453a609251588ed..414681bd91793faa6d135b4417e1f3dc2d8931f1 100644 (file)
@@ -25,15 +25,13 @@ class AddOracleIdTriggers < ActiveRecord::Migration
 
   def self.up
     case dialect()
-    when "oracle"
+    when 'oracle'
       upgrade_oracle()
     else
       # Do nothing
     end
   end
 
-  private
-
   def self.upgrade_oracle
     create_id_trigger('action_plans')
     create_id_trigger('active_dashboards')