]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5471 move creation of 5.6+ indices to Java migrations
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 7 Dec 2016 13:02:14 +0000 (14:02 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 12 Dec 2016 12:05:19 +0000 (13:05 +0100)
59 files changed:
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1152_remove_useless_indexes_on_group_roles.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1200_create_perm_templates_characteristics.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1204_make_uuid_columns_not_null_on_resource_index.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1205_drop_resource_index_rid_from_resource_index.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1210_create_temporary_indices_for_1211.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1212_drop_temporary_indices_of_1210.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1213_make_component_uuid_columns_not_null_on_snapshots.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1214_drop_snapshot_project_id_from_snapshots.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1221_add_index_on_component_uuid_of_measures.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1227_drop_index_projects_uuid_from_projects.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1228_make_uuid_columns_not_null_on_projects.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1229_recreate_index_projects_uuid_from_projects.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1230_drop_index_projects_root_id_from_projects.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1235_add_unique_index_on_uuid_of_snapshots.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1242_make_component_uuid_and_analysis_uuid_not_null_on_duplications_index.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1243_drop_index_duplications_index_sid_from_duplications_index.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1252_make_analysis_uuid_not_null_on_events.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1253_drop_index_events_snapshot_id_from_events.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1266_add_index_on_analysis_uuid_of_measures.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1269_temporarily_drop_index_of_analysis_uuid_on_measures.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1271_add_again_index_on_analysis_uuid_of_measures.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1273_drop_indices_on_tree_columns_of_snapshots.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1275_drop_index_on_snapshot_id_of_measures.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1312_create_table_properties_2.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1314_drop_table_properties.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1318_drop_table_activities.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1400_create_table_organizations.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1418_include_organization_uuid_in_unique_index_of_group_roles.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1502_make_uuid_not_null_on_events.rb
sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java
sonar-db/src/main/java/org/sonar/db/version/v56/RemoveUselessIndexesOnGroupRoles.java [new file with mode: 0644]
sonar-db/src/main/java/org/sonar/db/version/v60/AddIndexOnAnalysisUuidOfMeasures.java [new file with mode: 0644]
sonar-db/src/main/java/org/sonar/db/version/v60/AddIndexOnComponentUuidOfMeasures.java [new file with mode: 0644]
sonar-db/src/main/java/org/sonar/db/version/v60/AddUniqueIndexOnUuidOfSnapshots.java [new file with mode: 0644]
sonar-db/src/main/java/org/sonar/db/version/v60/CreatePermTemplatesCharacteristics.java [new file with mode: 0644]
sonar-db/src/main/java/org/sonar/db/version/v60/CreateTemporaryIndicesFor1211.java [new file with mode: 0644]
sonar-db/src/main/java/org/sonar/db/version/v60/DropIndexDuplicationsIndexSidFromDuplicationsIndex.java [new file with mode: 0644]
sonar-db/src/main/java/org/sonar/db/version/v60/DropIndexEventsSnapshotIdFromEvents.java [new file with mode: 0644]
sonar-db/src/main/java/org/sonar/db/version/v60/DropIndexOnSnapshotIdOfMeasures.java [new file with mode: 0644]
sonar-db/src/main/java/org/sonar/db/version/v60/DropIndexProjectsRootIdFromProjects.java [new file with mode: 0644]
sonar-db/src/main/java/org/sonar/db/version/v60/DropIndexProjectsUuidFromProjects.java [new file with mode: 0644]
sonar-db/src/main/java/org/sonar/db/version/v60/DropIndicesOnTreeColumnsOfSnapshots.java [new file with mode: 0644]
sonar-db/src/main/java/org/sonar/db/version/v60/DropResourceIndexRidFromResourceIndex.java [new file with mode: 0644]
sonar-db/src/main/java/org/sonar/db/version/v60/DropSnapshotProjectIdFromSnapshots.java [new file with mode: 0644]
sonar-db/src/main/java/org/sonar/db/version/v60/DropTemporaryIndicesOf1210.java [new file with mode: 0644]
sonar-db/src/main/java/org/sonar/db/version/v60/MakeAnalysisUuidNotNullOnEvents.java
sonar-db/src/main/java/org/sonar/db/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex.java
sonar-db/src/main/java/org/sonar/db/version/v60/MakeComponentUuidColumnsNotNullOnSnapshots.java
sonar-db/src/main/java/org/sonar/db/version/v60/MakeUuidColumnsNotNullOnProjects.java
sonar-db/src/main/java/org/sonar/db/version/v60/MakeUuidColumnsNotNullOnResourceIndex.java
sonar-db/src/main/java/org/sonar/db/version/v60/RecreateIndexProjectsUuidFromProjects.java [new file with mode: 0644]
sonar-db/src/main/java/org/sonar/db/version/v60/TemporarilyDropIndexOfAnalysisUuidOnMeasures.java [new file with mode: 0644]
sonar-db/src/main/java/org/sonar/db/version/v61/CreateTableProperties2.java
sonar-db/src/main/java/org/sonar/db/version/v61/DropTableActivities.java [new file with mode: 0644]
sonar-db/src/main/java/org/sonar/db/version/v61/DropTableProperties.java [new file with mode: 0644]
sonar-db/src/main/java/org/sonar/db/version/v62/CreateTableOrganizations.java
sonar-db/src/main/java/org/sonar/db/version/v62/IncludeOrganizationUuidInUniqueIndexOfGroupRoles.java [new file with mode: 0644]
sonar-db/src/main/java/org/sonar/db/version/v63/MakeUuidNotNullOnEvents.java
sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java

index fb0d14e3965f85236c0a5aff4a6cc3ef08ecd2e9..47f831048f367d3655e795c337af5c69618e412c 100644 (file)
@@ -25,8 +25,7 @@
 class RemoveUselessIndexesOnGroupRoles < ActiveRecord::Migration
 
   def self.up
-    remove_index :group_roles, :name => 'group_roles_group'
-    remove_index :group_roles, :name => 'group_roles_role'
+    execute_java_migration('org.sonar.db.version.v56.RemoveUselessIndexesOnGroupRoles')
   end
 
 end
index d84fc3e034ad778c5dbfdb6078fcbedd4858ca4d..4ea89cdb1f3309724dcb877d481eb4d31a85781a 100644 (file)
 class CreatePermTemplatesCharacteristics < ActiveRecord::Migration
 
   def self.up
-    create_table 'perm_tpl_characteristics' do |t|
-      t.column :template_id, :integer, :null => false
-      t.column :permission_key, :string, :null => false, :limit => 64
-      t.column :with_project_creator, :boolean, :null => false, :default => false
-      t.column :created_at, :big_integer, :null => false
-      t.column :updated_at, :big_integer, :null => false
-    end
-
-    add_index 'perm_tpl_characteristics', ['template_id','permission_key'], :name => 'uniq_perm_tpl_charac', :unique => true
+    execute_java_migration('org.sonar.db.version.v60.CreatePermTemplatesCharacteristics')
   end
 
 end
index f9e37e03d7947894af512a8002367c2d65622307..915966315b56433cca3a43204106dfbe64e0a6a9 100644 (file)
@@ -25,7 +25,5 @@ class MakeUuidColumnsNotNullOnResourceIndex < ActiveRecord::Migration
 
   def self.up
     execute_java_migration('org.sonar.db.version.v60.MakeUuidColumnsNotNullOnResourceIndex')
-
-    add_index :resource_index, :component_uuid, :name => 'resource_index_component'
   end
 end
index 301bc54182cc78930dc6418130a3c3cf289f9221..b41df473bdb52c0280e08a83ed1f03fd2d83e3df 100644 (file)
 class DropResourceIndexRidFromResourceIndex < ActiveRecord::Migration
 
   def self.up
-    begin
-      remove_index :resource_index, :name => 'resource_index_rid'
-    rescue
-      #ignore
-    end
+    execute_java_migration('org.sonar.db.version.v60.DropResourceIndexRidFromResourceIndex')
   end
 end
index 736441e04e7366a4140cc0294c0ee11155c65095..adaa6baf1c88b005a46d0441a70fe14edaefaed4 100644 (file)
@@ -24,7 +24,6 @@
 class CreateTemporaryIndicesFor1211 < ActiveRecord::Migration
 
   def self.up
-    add_index :ce_activity, :snapshot_id, :name => 'ce_activity_snapshot_id'
-    add_index :duplications_index, :project_snapshot_id, :name => 'dup_index_psid'
+    execute_java_migration('org.sonar.db.version.v60.CreateTemporaryIndicesFor1211')
   end
 end
index 8144ec86e455f38a2fc31d36020360b3826d2774..c5193f927b7dd78b64b9085bd0b88065e793b56c 100644 (file)
 class DropTemporaryIndicesOf1210 < ActiveRecord::Migration
 
   def self.up
-    drop_index_quietly :ce_activity, 'ce_activity_snapshot_id'
-    drop_index_quietly :duplications_index, 'dup_index_psid'
+    execute_java_migration('org.sonar.db.version.v60.DropTemporaryIndicesOf1210')
   end
 
-  private
-
-  def self.drop_index_quietly(table, index)
-    begin
-      remove_index table, :name => index
-    rescue
-      #ignore
-    end
-  end
 end
index 2991af91b8826cff54186e06b67d327d9e506162..cec3b032a2bfa937749f2d2069163577372b6e55 100644 (file)
@@ -25,8 +25,5 @@ class MakeComponentUuidColumnsNotNullOnSnapshots < ActiveRecord::Migration
 
   def self.up
     execute_java_migration('org.sonar.db.version.v60.MakeComponentUuidColumnsNotNullOnSnapshots')
-
-    add_index :snapshots, :component_uuid, :name => 'snapshot_component'
-    add_index :snapshots, :root_component_uuid, :name => 'snapshot_root_component'
   end
 end
index 0d3854fe88c29337a9edab6910187ff4b964f5c6..bb9ddc23aabbb826c187f63e77b06b1c4383085b 100644 (file)
 class DropSnapshotProjectIdFromSnapshots < ActiveRecord::Migration
 
   def self.up
-    begin
-      remove_index :snapshots, :name => 'snapshot_project_id'
-    rescue
-      #ignore
-    end
-    begin
-      remove_index :snapshots, :name => 'snapshots_root_project_id'
-    rescue
-      #ignore
-    end
+    execute_java_migration('org.sonar.db.version.v60.DropSnapshotProjectIdFromSnapshots')
   end
 end
index 764a32f8fae8b9e6dd4255699c9a60d871c14c4b..17273925c3e370bee534a2309de2cd18aa923960 100644 (file)
@@ -24,6 +24,7 @@
 class AddIndexOnComponentUuidOfMeasures < ActiveRecord::Migration
 
   def self.up
-    add_index :project_measures, :component_uuid, :name => 'measures_component_uuid'
+    execute_java_migration('org.sonar.db.version.v60.AddIndexOnComponentUuidOfMeasures')
   end
+
 end
index a454b714deb1dbd8bb7dde7061266160331abaf1..ab2419fb6345889c328344e9a5761eb66b5eb11c 100644 (file)
 class DropIndexProjectsUuidFromProjects < ActiveRecord::Migration
 
   def self.up
-    begin
-      remove_index :projects, :name => 'projects_uuid'
-    rescue
-      #ignore
-    end
+    execute_java_migration('org.sonar.db.version.v60.DropIndexProjectsUuidFromProjects')
   end
 end
index ae98cc7a0d5b67fe7ef14f4d110b19cc12997885..684ca3d7a1534c7af9a77cad003d16c08c5a91a0 100644 (file)
@@ -25,7 +25,5 @@ class MakeUuidColumnsNotNullOnProjects < ActiveRecord::Migration
 
   def self.up
     execute_java_migration('org.sonar.db.version.v60.MakeUuidColumnsNotNullOnProjects')
-
-    add_index :projects, :root_uuid, :name => 'projects_root_uuid'
   end
 end
index 35687314ab2e038f515c3eb0a99828226da95e72..52deb0462230a015a5d4a5884cc058a1511ace96 100644 (file)
@@ -25,6 +25,6 @@
 class RecreateIndexProjectsUuidFromProjects < ActiveRecord::Migration
 
   def self.up
-    add_index :projects, :uuid, :name => 'projects_uuid'
+    execute_java_migration('org.sonar.db.version.v60.RecreateIndexProjectsUuidFromProjects')
   end
 end
index 21209cb48cf40edd69b44435a9ed4a90f35c5ab3..1e0b606af0b1dd47a7772680f3599cc2da30e3e7 100644 (file)
 class DropIndexProjectsRootIdFromProjects < ActiveRecord::Migration
 
   def self.up
-    begin
-      remove_index :projects, :name => 'projects_root_id'
-    rescue
-      #ignore
-    end
+    execute_java_migration('org.sonar.db.version.v60.DropIndexProjectsRootIdFromProjects')
   end
 end
index 973add64ea6381cfbed1d79a5b64c9cfdc2fa1f5..498397fcd6d2aef5dd9e46c20db53b2df2ac0360 100644 (file)
@@ -24,6 +24,6 @@
 class AddUniqueIndexOnUuidOfSnapshots < ActiveRecord::Migration
 
   def self.up
-    add_index :snapshots, :uuid, :name => 'analyses_uuid', :unique => true
+    execute_java_migration('org.sonar.db.version.v60.AddUniqueIndexOnUuidOfSnapshots')
   end
 end
index 72e090fe5098c78140c49818f8fef8ce64c5150b..171d3750870dd9a06d71b3ec26e50fda6e49927c 100644 (file)
@@ -25,7 +25,5 @@ class MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex < ActiveRecord:
 
   def self.up
     execute_java_migration('org.sonar.db.version.v60.MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex')
-
-    add_index :duplications_index, [:analysis_uuid, :component_uuid], :name => 'duplication_analysis_component'
   end
 end
index a2e53fef31850b2db274f78456de00d94866e118..69f4ed2404feb29189bb8cd73a6d3940bbbcf631 100644 (file)
 class DropIndexDuplicationsIndexSidFromDuplicationsIndex < ActiveRecord::Migration
 
   def self.up
-    begin
-      remove_index :duplications_index, :name => 'duplications_index_sid'
-    rescue
-      #ignore
-    end
+    execute_java_migration('org.sonar.db.version.v60.DropIndexDuplicationsIndexSidFromDuplicationsIndex')
   end
 end
index 294714a6b80f357dc3e0d3f52836172c10cb3dd0..e9d5bf66abfed5b3201285dbc972b144231b9496 100644 (file)
@@ -25,7 +25,5 @@ class MakeAnalysisUuidNotNullOnEvents < ActiveRecord::Migration
 
   def self.up
     execute_java_migration('org.sonar.db.version.v60.MakeAnalysisUuidNotNullOnEvents')
-
-    add_index :events, :analysis_uuid, :name => 'events_analysis'
   end
 end
index fdadd1aebeee45ec0b6e3785c247b4b739d542b3..4c6206651ca84c63b7c30330d180514f8d5b7495 100644 (file)
 class DropIndexEventsSnapshotIdFromEvents < ActiveRecord::Migration
 
   def self.up
-    begin
-      remove_index :events, :name => 'events_snapshot_id'
-    rescue
-      #ignore
-    end
+    execute_java_migration('org.sonar.db.version.v60.DropIndexEventsSnapshotIdFromEvents')
   end
 end
index 02b6a22bccf6690dc1d9e018fa3ab1736d9c05f1..afee48952a52b5578b89b3832c2110e7cf8e7da3 100644 (file)
@@ -24,7 +24,6 @@
 class AddIndexOnAnalysisUuidOfMeasures < ActiveRecord::Migration
 
   def self.up
-    # this index must be present for the performance of next migration
-    add_index :project_measures, [:analysis_uuid, :metric_id], :name => 'measures_analysis_metric'
+    execute_java_migration('org.sonar.db.version.v60.AddIndexOnAnalysisUuidOfMeasures')
   end
 end
index 99c59a3d35f024f4bd368041a34ad231ff1d08c0..1ecbdf3e39281126cbf68edb5599adf08ff3639a 100644 (file)
@@ -24,8 +24,6 @@
 class TemporarilyDropIndexOfAnalysisUuidOnMeasures < ActiveRecord::Migration
 
   def self.up
-    # the index must be dropped for the compatibility of migration 1270
-    # with MSSQL
-    remove_index :project_measures, :name => 'measures_analysis_metric'
+    execute_java_migration('org.sonar.db.version.v60.TemporarilyDropIndexOfAnalysisUuidOnMeasures')
   end
 end
index 7f70785815ba7b01605b2f71f67c8513b675778d..71d768a21936f1cf4f947fee51ad5fe8575600e4 100644 (file)
@@ -24,6 +24,6 @@
 class AddAgainIndexOnAnalysisUuidOfMeasures < ActiveRecord::Migration
 
   def self.up
-    add_index :project_measures, [:analysis_uuid, :metric_id], :name => 'measures_analysis_metric'
+    execute_java_migration('org.sonar.db.version.v60.AddIndexOnAnalysisUuidOfMeasures')
   end
 end
index 343ca0e598359f987e5018631b6c0c38de4d84bb..553e29a45e2ad5e24625dcdf0288392189d9f7ea 100644 (file)
 class DropIndicesOnTreeColumnsOfSnapshots < ActiveRecord::Migration
 
   def self.up
-    remove_index_quietly 'snapshots_qualifier'
-    remove_index_quietly 'snapshots_root'
-    remove_index_quietly 'snapshots_parent'
-    remove_index_quietly 'snapshot_root_component'
+    execute_java_migration('org.sonar.db.version.v60.DropIndicesOnTreeColumnsOfSnapshots')
   end
 
-  private
-  def self.remove_index_quietly(index_name)
-    begin
-      remove_index :snapshots, :name => index_name
-    rescue
-      #ignore
-    end
-  end
 end
index 79ce1df6e2738e278a59667e08207f0712caba00..4f494796782d3b83f9021fcb26c6fd095d024bd6 100644 (file)
 class DropIndexOnSnapshotIdOfMeasures < ActiveRecord::Migration
 
   def self.up
-    begin
-      remove_index :project_measures, :name => 'measures_sid_metric'
-    rescue
-      #ignore
-    end
+    execute_java_migration('org.sonar.db.version.v60.DropIndexOnSnapshotIdOfMeasures')
   end
 
 end
index 075cad0d511b62185cb925eaedf0ebf9fc606b83..fe4686c17e501a64f3ad67a84471fc0595346f78 100644 (file)
@@ -25,6 +25,5 @@ class CreateTableProperties2 < ActiveRecord::Migration
 
   def self.up
     execute_java_migration('org.sonar.db.version.v61.CreateTableProperties2')
-    add_varchar_index :properties2, :prop_key, :name => 'properties2_key'
   end
 end
index 2815d353676ed9ff67b37ac3c50f23c06d16432b..bef5d32ffa4cde1ea65b6937e048107d102df0a1 100644 (file)
@@ -24,8 +24,7 @@
 class DropTableProperties < ActiveRecord::Migration
 
   def self.up
-    drop_index_quietly :properties, :properties_key
-    drop_table :properties
+    execute_java_migration('org.sonar.db.version.v61.DropTableProperties')
   end
 
 end
index 988b0336ce5fd1af7218827ab4c8183afb958eaa..9e7cc271af07ed23edd816201f3564fce867c020 100644 (file)
@@ -24,8 +24,7 @@
 class DropTableActivities < ActiveRecord::Migration
 
   def self.up
-    drop_index_quietly 'activities', 'activities_log_key'
-    drop_table 'activities'
+    execute_java_migration('org.sonar.db.version.v61.DropTableActivities')
   end
 
 end
index 0c2105aabd67ede42c26a9d58eddc7f0e45b228e..61aa3c0fcd46cca9eb840579194136328067fb43 100644 (file)
@@ -25,6 +25,5 @@ class CreateTableOrganizations < ActiveRecord::Migration
 
   def self.up
     execute_java_migration('org.sonar.db.version.v62.CreateTableOrganizations')
-    add_index :organizations, :kee, :name => 'organization_key'
   end
 end
index dc7b15aaffeacfdf95e85d7e048d99cea5fe5c78..5aa3a84462546c6641411e5a9e59bb26e4944fe7 100644 (file)
@@ -24,8 +24,6 @@
 class IncludeOrganizationUuidInUniqueIndexOfGroupRoles < ActiveRecord::Migration
 
   def self.up
-    drop_index_quietly :group_roles, :uniq_group_roles
-
-    add_index 'group_roles', ['organization_uuid', 'group_id', 'resource_id', 'role'], :unique => true, :name => 'uniq_group_roles'
+    execute_java_migration('org.sonar.db.version.v62.IncludeOrganizationUuidInUniqueIndexOfGroupRoles')
   end
 end
index 02110478a03776719ad6062d1e5bf1792c7fa51e..8aee750daf7b9ea2deb18c0d642889a1c3637912 100644 (file)
@@ -25,6 +25,5 @@ class MakeUuidNotNullOnEvents < ActiveRecord::Migration
 
   def self.up
     execute_java_migration('org.sonar.db.version.v63.MakeUuidNotNullOnEvents')
-    add_index 'events', :uuid, :name => 'events_uuid', :unique => true
   end
 end
index 6267b24e2e29c93354ba13d93bf7014615bef7c0..d687d760a976fd6bb9c92e12b5d26512db42e096 100644 (file)
@@ -83,6 +83,7 @@ import org.sonar.db.version.v55.FeedRulesLongDateColumns;
 import org.sonar.db.version.v55.FeedRulesTypes;
 import org.sonar.db.version.v56.FixLengthOfIssuesMessageOnOracle;
 import org.sonar.db.version.v56.FixTypeOfRuleTypeOnMysql;
+import org.sonar.db.version.v56.RemoveUselessIndexesOnGroupRoles;
 import org.sonar.db.version.v56.UpdateUsersExternalIdentityWhenEmpty;
 import org.sonar.db.version.v60.AddAnalysisUuidColumnToCeActivity;
 import org.sonar.db.version.v60.AddAnalysisUuidColumnToEvents;
@@ -91,8 +92,11 @@ import org.sonar.db.version.v60.AddBColumnsToProjects;
 import org.sonar.db.version.v60.AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndex;
 import org.sonar.db.version.v60.AddComponentUuidColumnToMeasures;
 import org.sonar.db.version.v60.AddComponentUuidColumnsToSnapshots;
+import org.sonar.db.version.v60.AddIndexOnAnalysisUuidOfMeasures;
+import org.sonar.db.version.v60.AddIndexOnComponentUuidOfMeasures;
 import org.sonar.db.version.v60.AddLastUsedColumnToRulesProfiles;
 import org.sonar.db.version.v60.AddProfileKeyToActivities;
+import org.sonar.db.version.v60.AddUniqueIndexOnUuidOfSnapshots;
 import org.sonar.db.version.v60.AddUserUpdatedAtToRulesProfiles;
 import org.sonar.db.version.v60.AddUuidColumnToSnapshots;
 import org.sonar.db.version.v60.AddUuidColumnsToProjects;
@@ -105,17 +109,28 @@ import org.sonar.db.version.v60.CleanOrphanRowsInProjects;
 import org.sonar.db.version.v60.CleanOrphanRowsInResourceIndex;
 import org.sonar.db.version.v60.CleanOrphanRowsInSnapshots;
 import org.sonar.db.version.v60.CleanUsurperRootComponents;
+import org.sonar.db.version.v60.CreatePermTemplatesCharacteristics;
+import org.sonar.db.version.v60.CreateTemporaryIndicesFor1211;
 import org.sonar.db.version.v60.DeleteOrphanDuplicationsIndexRowsWithoutComponentOrAnalysis;
 import org.sonar.db.version.v60.DeleteOrphanMeasuresWithoutComponent;
 import org.sonar.db.version.v60.DropIdColumnsFromProjects;
 import org.sonar.db.version.v60.DropIdColumnsFromResourceIndex;
 import org.sonar.db.version.v60.DropIdColumnsFromSnapshots;
+import org.sonar.db.version.v60.DropIndexDuplicationsIndexSidFromDuplicationsIndex;
+import org.sonar.db.version.v60.DropIndexEventsSnapshotIdFromEvents;
+import org.sonar.db.version.v60.DropIndexOnSnapshotIdOfMeasures;
+import org.sonar.db.version.v60.DropIndexProjectsRootIdFromProjects;
+import org.sonar.db.version.v60.DropIndexProjectsUuidFromProjects;
+import org.sonar.db.version.v60.DropIndicesOnTreeColumnsOfSnapshots;
 import org.sonar.db.version.v60.DropProjectIdColumnFromMeasures;
 import org.sonar.db.version.v60.DropRememberMeColumnsFromUsers;
+import org.sonar.db.version.v60.DropResourceIndexRidFromResourceIndex;
 import org.sonar.db.version.v60.DropSnapshotIdColumnFromCeActivity;
 import org.sonar.db.version.v60.DropSnapshotIdColumnFromEvents;
 import org.sonar.db.version.v60.DropSnapshotIdColumnFromMeasures;
 import org.sonar.db.version.v60.DropSnapshotIdColumnsFromDuplicationsIndex;
+import org.sonar.db.version.v60.DropSnapshotProjectIdFromSnapshots;
+import org.sonar.db.version.v60.DropTemporaryIndicesOf1210;
 import org.sonar.db.version.v60.DropTreeColumnsFromSnapshots;
 import org.sonar.db.version.v60.DropTreesOfSnapshots;
 import org.sonar.db.version.v60.DropUnusedMeasuresColumns;
@@ -143,7 +158,9 @@ import org.sonar.db.version.v60.PopulateUuidColumnOnSnapshots;
 import org.sonar.db.version.v60.PopulateUuidColumnsOfProjects;
 import org.sonar.db.version.v60.PopulateUuidColumnsOfResourceIndex;
 import org.sonar.db.version.v60.PopulateUuidPathColumnOnProjects;
+import org.sonar.db.version.v60.RecreateIndexProjectsUuidFromProjects;
 import org.sonar.db.version.v60.RemoveUsersPasswordWhenNotLocal;
+import org.sonar.db.version.v60.TemporarilyDropIndexOfAnalysisUuidOnMeasures;
 import org.sonar.db.version.v61.AddBUuidPathToProjects;
 import org.sonar.db.version.v61.AddErrorColumnsToCeActivity;
 import org.sonar.db.version.v61.CopyActivitiesToQprofileChanges;
@@ -156,6 +173,8 @@ import org.sonar.db.version.v61.CreateTableScannerContext;
 import org.sonar.db.version.v61.DeleteProjectDashboards;
 import org.sonar.db.version.v61.DeleteReportsFromCeQueue;
 import org.sonar.db.version.v61.DropIsGlobalFromDashboards;
+import org.sonar.db.version.v61.DropTableActivities;
+import org.sonar.db.version.v61.DropTableProperties;
 import org.sonar.db.version.v61.PopulateTableProperties2;
 import org.sonar.db.version.v61.RemoveViewsDefinitionFromProperties;
 import org.sonar.db.version.v61.ShrinkModuleUuidPathOfProjects;
@@ -171,6 +190,7 @@ import org.sonar.db.version.v62.DeletePermissionShareDashboard;
 import org.sonar.db.version.v62.DropIssueFiltersTables;
 import org.sonar.db.version.v62.DropMeasureFiltersTables;
 import org.sonar.db.version.v62.DropRelatedDashboardTables;
+import org.sonar.db.version.v62.IncludeOrganizationUuidInUniqueIndexOfGroupRoles;
 import org.sonar.db.version.v62.MakeOrganizationUuidNotNullOnGroupRoles;
 import org.sonar.db.version.v62.MakeOrganizationUuidNotNullOnGroups;
 import org.sonar.db.version.v62.MakeOrganizationUuidNotNullOnPermissionTemplates;
@@ -266,6 +286,7 @@ public class MigrationStepModule extends Module {
       DeleteManualRules.class,
 
       // 5.6
+      RemoveUselessIndexesOnGroupRoles.class,
       FixTypeOfRuleTypeOnMysql.class,
       FixLengthOfIssuesMessageOnOracle.class,
       UpdateUsersExternalIdentityWhenEmpty.class,
@@ -300,6 +321,11 @@ public class MigrationStepModule extends Module {
       MakeProfileKeyNotNullOnActivities.class,
       AddUserUpdatedAtToRulesProfiles.class,
       PopulateUserUpdatedAtOfRulesProfiles.class,
+      CreateTemporaryIndicesFor1211.class,
+      AddIndexOnComponentUuidOfMeasures.class,
+      RecreateIndexProjectsUuidFromProjects.class,
+      AddUniqueIndexOnUuidOfSnapshots.class,
+      AddIndexOnAnalysisUuidOfMeasures.class,
 
       // SNAPSHOTS.UUID
       AddUuidColumnToSnapshots.class,
@@ -346,6 +372,17 @@ public class MigrationStepModule extends Module {
       DropTreeColumnsFromSnapshots.class,
       DropSnapshotIdColumnFromMeasures.class,
       AddBColumnsToProjects.class,
+      CreatePermTemplatesCharacteristics.class,
+      DropTemporaryIndicesOf1210.class,
+      DropResourceIndexRidFromResourceIndex.class,
+      DropSnapshotProjectIdFromSnapshots.class,
+      DropIndexProjectsUuidFromProjects.class,
+      DropIndexProjectsRootIdFromProjects.class,
+      DropIndexDuplicationsIndexSidFromDuplicationsIndex.class,
+      DropIndexEventsSnapshotIdFromEvents.class,
+      TemporarilyDropIndexOfAnalysisUuidOnMeasures.class,
+      DropIndexOnSnapshotIdOfMeasures.class,
+      DropIndicesOnTreeColumnsOfSnapshots.class,
 
       // 6.1
       DeleteProjectDashboards.class,
@@ -363,6 +400,8 @@ public class MigrationStepModule extends Module {
       CreateTableQprofileChanges.class,
       CopyActivitiesToQprofileChanges.class,
       CreateTableRuleRepositories.class,
+      DropTableActivities.class,
+      DropTableProperties.class,
 
       // 6.2
       CreateTableOrganizations.class,
@@ -388,6 +427,7 @@ public class MigrationStepModule extends Module {
       DropMeasureFiltersTables.class,
       DropIssueFiltersTables.class,
       CreateTableWebhookDeliveries.class,
+      IncludeOrganizationUuidInUniqueIndexOfGroupRoles.class,
 
       // 6.3
       AddUuidToEvents.class,
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v56/RemoveUselessIndexesOnGroupRoles.java b/sonar-db/src/main/java/org/sonar/db/version/v56/RemoveUselessIndexesOnGroupRoles.java
new file mode 100644 (file)
index 0000000..36f1663
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.db.version.v56;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.DropIndexBuilder;
+
+/**
+ * SONAR-6613
+ */
+public class RemoveUselessIndexesOnGroupRoles extends DdlChange {
+
+  private static final String TABLE_NAME = "group_roles";
+
+  public RemoveUselessIndexesOnGroupRoles(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new DropIndexBuilder(getDialect())
+      .setTable(TABLE_NAME)
+      .setName("group_roles_group")
+      .build());
+
+    context.execute(new DropIndexBuilder(getDialect())
+      .setTable(TABLE_NAME)
+      .setName("group_roles_role")
+      .build());
+  }
+}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/AddIndexOnAnalysisUuidOfMeasures.java b/sonar-db/src/main/java/org/sonar/db/version/v60/AddIndexOnAnalysisUuidOfMeasures.java
new file mode 100644 (file)
index 0000000..b1dc968
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.CreateIndexBuilder;
+import org.sonar.db.version.DdlChange;
+
+import static org.sonar.db.version.IntegerColumnDef.newIntegerColumnDefBuilder;
+import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder;
+
+public class AddIndexOnAnalysisUuidOfMeasures extends DdlChange {
+
+  public AddIndexOnAnalysisUuidOfMeasures(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    // this index must be present for the performance of next migration
+    context.execute(new CreateIndexBuilder(getDialect())
+      .setTable("project_measures")
+      .setName("measures_analysis_metric")
+      .addColumn(newVarcharColumnDefBuilder().setColumnName("analysis_uuid").setLimit(50).build())
+      .addColumn(newIntegerColumnDefBuilder().setColumnName("metric_id").build())
+      .build());
+  }
+}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/AddIndexOnComponentUuidOfMeasures.java b/sonar-db/src/main/java/org/sonar/db/version/v60/AddIndexOnComponentUuidOfMeasures.java
new file mode 100644 (file)
index 0000000..7f408c8
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.CreateIndexBuilder;
+import org.sonar.db.version.DdlChange;
+
+import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder;
+
+public class AddIndexOnComponentUuidOfMeasures extends DdlChange {
+
+  public AddIndexOnComponentUuidOfMeasures(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new CreateIndexBuilder(getDialect())
+      .setTable("project_measures")
+      .setName("measures_component_uuid")
+      .addColumn(newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(50).build())
+      .build());
+  }
+
+}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/AddUniqueIndexOnUuidOfSnapshots.java b/sonar-db/src/main/java/org/sonar/db/version/v60/AddUniqueIndexOnUuidOfSnapshots.java
new file mode 100644 (file)
index 0000000..a3ac5a8
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.CreateIndexBuilder;
+import org.sonar.db.version.DdlChange;
+
+import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder;
+
+public class AddUniqueIndexOnUuidOfSnapshots extends DdlChange {
+
+  public AddUniqueIndexOnUuidOfSnapshots(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new CreateIndexBuilder(getDialect())
+      .setTable("snapshots")
+      .setName("analyses_uuid")
+      .addColumn(newVarcharColumnDefBuilder().setColumnName("uuid").setLimit(50).build())
+      .setUnique(true)
+      .build());
+  }
+}
+
+
+
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/CreatePermTemplatesCharacteristics.java b/sonar-db/src/main/java/org/sonar/db/version/v60/CreatePermTemplatesCharacteristics.java
new file mode 100644 (file)
index 0000000..63ef5dd
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.CreateIndexBuilder;
+import org.sonar.db.version.CreateTableBuilder;
+import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.IntegerColumnDef;
+import org.sonar.db.version.VarcharColumnDef;
+
+import static org.sonar.db.version.BigIntegerColumnDef.newBigIntegerColumnDefBuilder;
+import static org.sonar.db.version.BooleanColumnDef.newBooleanColumnDefBuilder;
+import static org.sonar.db.version.CreateTableBuilder.ColumnFlag.AUTO_INCREMENT;
+import static org.sonar.db.version.IntegerColumnDef.newIntegerColumnDefBuilder;
+import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder;
+
+public class CreatePermTemplatesCharacteristics extends DdlChange {
+
+  private static final String TABLE_NAME = "perm_tpl_characteristics";
+
+  public CreatePermTemplatesCharacteristics(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    IntegerColumnDef templateIdColumn = newIntegerColumnDefBuilder().setColumnName("template_id").setIsNullable(false).build();
+    VarcharColumnDef permissionKeyColumn = newVarcharColumnDefBuilder().setColumnName("permission_key").setLimit(64).setIsNullable(false).build();
+    context.execute(
+      new CreateTableBuilder(getDialect(), TABLE_NAME)
+        .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT)
+        .addColumn(templateIdColumn)
+        .addColumn(permissionKeyColumn)
+        .addColumn(newBooleanColumnDefBuilder().setColumnName("with_project_creator").setIsNullable(false).setDefaultValue(false).build())
+        .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build())
+        .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(false).build())
+        .build());
+
+    context.execute(new CreateIndexBuilder(getDialect())
+      .setTable(TABLE_NAME)
+      .setName("uniq_perm_tpl_charac")
+      .setUnique(true)
+      .addColumn(templateIdColumn)
+      .addColumn(permissionKeyColumn)
+      .build());
+  }
+}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/CreateTemporaryIndicesFor1211.java b/sonar-db/src/main/java/org/sonar/db/version/v60/CreateTemporaryIndicesFor1211.java
new file mode 100644 (file)
index 0000000..b1e561f
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.CreateIndexBuilder;
+import org.sonar.db.version.DdlChange;
+
+import static org.sonar.db.version.IntegerColumnDef.newIntegerColumnDefBuilder;
+
+public class CreateTemporaryIndicesFor1211 extends DdlChange {
+
+  public static final String INDEX_ON_CE_ACTIVITY = "ce_activity_snapshot_id";
+  public static final String INDEX_ON_DUPLICATIONS_INDEX = "dup_index_psid";
+
+  public CreateTemporaryIndicesFor1211(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new CreateIndexBuilder(getDialect())
+      .setTable("ce_activity")
+      .setName(INDEX_ON_CE_ACTIVITY)
+      .addColumn(newIntegerColumnDefBuilder().setColumnName("snapshot_id").build())
+      .build());
+    context.execute(new CreateIndexBuilder(getDialect())
+      .setTable("duplications_index")
+      .setName(INDEX_ON_DUPLICATIONS_INDEX)
+      .addColumn(newIntegerColumnDefBuilder().setColumnName("project_snapshot_id").build())
+      .build());
+  }
+}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/DropIndexDuplicationsIndexSidFromDuplicationsIndex.java b/sonar-db/src/main/java/org/sonar/db/version/v60/DropIndexDuplicationsIndexSidFromDuplicationsIndex.java
new file mode 100644 (file)
index 0000000..0c1a8a0
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.DropIndexBuilder;
+
+public class DropIndexDuplicationsIndexSidFromDuplicationsIndex extends DdlChange {
+  public DropIndexDuplicationsIndexSidFromDuplicationsIndex(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new DropIndexBuilder(getDialect())
+      .setTable("duplications_index")
+      .setName("duplications_index_sid")
+      .build());
+  }
+}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/DropIndexEventsSnapshotIdFromEvents.java b/sonar-db/src/main/java/org/sonar/db/version/v60/DropIndexEventsSnapshotIdFromEvents.java
new file mode 100644 (file)
index 0000000..f6a6129
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.DropIndexBuilder;
+
+public class DropIndexEventsSnapshotIdFromEvents extends DdlChange {
+  public DropIndexEventsSnapshotIdFromEvents(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new DropIndexBuilder(getDialect())
+      .setTable("events")
+      .setName("events_snapshot_id")
+      .build());
+  }
+}
+
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/DropIndexOnSnapshotIdOfMeasures.java b/sonar-db/src/main/java/org/sonar/db/version/v60/DropIndexOnSnapshotIdOfMeasures.java
new file mode 100644 (file)
index 0000000..24ba93d
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.DropIndexBuilder;
+
+public class DropIndexOnSnapshotIdOfMeasures extends DdlChange {
+  public DropIndexOnSnapshotIdOfMeasures(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new DropIndexBuilder(getDialect())
+      .setTable("project_measures")
+      .setName("measures_sid_metric")
+      .build());
+  }
+}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/DropIndexProjectsRootIdFromProjects.java b/sonar-db/src/main/java/org/sonar/db/version/v60/DropIndexProjectsRootIdFromProjects.java
new file mode 100644 (file)
index 0000000..c04bdf2
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.DropIndexBuilder;
+
+public class DropIndexProjectsRootIdFromProjects extends DdlChange {
+  public DropIndexProjectsRootIdFromProjects(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new DropIndexBuilder(getDialect())
+      .setTable("projects")
+      .setName("projects_root_id")
+      .build());
+  }
+}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/DropIndexProjectsUuidFromProjects.java b/sonar-db/src/main/java/org/sonar/db/version/v60/DropIndexProjectsUuidFromProjects.java
new file mode 100644 (file)
index 0000000..cf6b154
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.DropIndexBuilder;
+
+public class DropIndexProjectsUuidFromProjects extends DdlChange {
+  public DropIndexProjectsUuidFromProjects(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new DropIndexBuilder(getDialect())
+      .setTable("projects")
+      .setName("projects_uuid")
+      .build());
+  }
+}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/DropIndicesOnTreeColumnsOfSnapshots.java b/sonar-db/src/main/java/org/sonar/db/version/v60/DropIndicesOnTreeColumnsOfSnapshots.java
new file mode 100644 (file)
index 0000000..266433a
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.DropIndexBuilder;
+
+public class DropIndicesOnTreeColumnsOfSnapshots extends DdlChange {
+  public DropIndicesOnTreeColumnsOfSnapshots(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    dropIndex(context, "snapshots_qualifier");
+    dropIndex(context, "snapshots_root");
+    dropIndex(context, "snapshots_parent");
+    dropIndex(context, "snapshot_root_component");
+  }
+
+  private void dropIndex(Context context, String index) throws SQLException {
+    context.execute(new DropIndexBuilder(getDialect())
+      .setTable("snapshots")
+      .setName(index)
+      .build());
+  }
+}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/DropResourceIndexRidFromResourceIndex.java b/sonar-db/src/main/java/org/sonar/db/version/v60/DropResourceIndexRidFromResourceIndex.java
new file mode 100644 (file)
index 0000000..8668ec9
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.DropIndexBuilder;
+
+public class DropResourceIndexRidFromResourceIndex extends DdlChange {
+
+  public DropResourceIndexRidFromResourceIndex(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new DropIndexBuilder(getDialect())
+      .setTable("resource_index")
+      .setName("resource_index_rid")
+      .build());
+  }
+
+}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/DropSnapshotProjectIdFromSnapshots.java b/sonar-db/src/main/java/org/sonar/db/version/v60/DropSnapshotProjectIdFromSnapshots.java
new file mode 100644 (file)
index 0000000..23d54c0
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.DropIndexBuilder;
+
+public class DropSnapshotProjectIdFromSnapshots extends DdlChange {
+
+  private static final String TABLE_SNAPSHOTS = "snapshots";
+
+  public DropSnapshotProjectIdFromSnapshots(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new DropIndexBuilder(getDialect())
+      .setTable(TABLE_SNAPSHOTS)
+      .setName("snapshot_project_id")
+      .build());
+    context.execute(new DropIndexBuilder(getDialect())
+      .setTable(TABLE_SNAPSHOTS)
+      .setName("snapshots_root_project_id")
+      .build());
+  }
+}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/DropTemporaryIndicesOf1210.java b/sonar-db/src/main/java/org/sonar/db/version/v60/DropTemporaryIndicesOf1210.java
new file mode 100644 (file)
index 0000000..45043bd
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.DropIndexBuilder;
+
+public class DropTemporaryIndicesOf1210 extends DdlChange {
+
+  public DropTemporaryIndicesOf1210(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new DropIndexBuilder(getDialect())
+      .setTable("ce_activity")
+      .setName(CreateTemporaryIndicesFor1211.INDEX_ON_CE_ACTIVITY)
+      .build());
+
+    context.execute(new DropIndexBuilder(getDialect())
+      .setTable("duplications_index")
+      .setName(CreateTemporaryIndicesFor1211.INDEX_ON_DUPLICATIONS_INDEX)
+      .build());
+  }
+
+}
index 97f82f3854f4011d3c9cc5ccd859a1ee04ab39f1..eb299e065fb87416d06cd76354ab660c84ad9ab5 100644 (file)
@@ -22,7 +22,9 @@ package org.sonar.db.version.v60;
 import java.sql.SQLException;
 import org.sonar.db.Database;
 import org.sonar.db.version.AlterColumnsBuilder;
+import org.sonar.db.version.CreateIndexBuilder;
 import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.VarcharColumnDef;
 
 import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE;
 import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder;
@@ -37,8 +39,15 @@ public class MakeAnalysisUuidNotNullOnEvents extends DdlChange {
 
   @Override
   public void execute(Context context) throws SQLException {
+    VarcharColumnDef analysisUuidColumn = newVarcharColumnDefBuilder().setColumnName("analysis_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build();
     context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), TABLE_EVENTS)
-      .updateColumn(newVarcharColumnDefBuilder().setColumnName("analysis_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build())
+      .updateColumn(analysisUuidColumn)
+      .build());
+
+    context.execute(new CreateIndexBuilder(getDialect())
+      .setTable(TABLE_EVENTS)
+      .setName("events_analysis")
+      .addColumn(analysisUuidColumn)
       .build());
   }
 
index 8d4866344063c253b52002cd0b1f4008b4960b67..e9f3a368e0617e9dd4cc220ff1fa6c33d885ad97 100644 (file)
@@ -22,7 +22,9 @@ package org.sonar.db.version.v60;
 import java.sql.SQLException;
 import org.sonar.db.Database;
 import org.sonar.db.version.AlterColumnsBuilder;
+import org.sonar.db.version.CreateIndexBuilder;
 import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.VarcharColumnDef;
 
 import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE;
 import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder;
@@ -37,9 +39,18 @@ public class MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex extends
 
   @Override
   public void execute(Context context) throws SQLException {
+    VarcharColumnDef analysisUuid = newVarcharColumnDefBuilder().setColumnName("analysis_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build();
+    VarcharColumnDef componentUuid = newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build();
     context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), TABLE_DUPLICATIONS_INDEX)
-      .updateColumn(newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build())
-      .updateColumn(newVarcharColumnDefBuilder().setColumnName("analysis_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build())
+      .updateColumn(componentUuid)
+      .updateColumn(analysisUuid)
+      .build());
+
+    context.execute(new CreateIndexBuilder(getDialect())
+      .setTable(TABLE_DUPLICATIONS_INDEX)
+      .setName("duplication_analysis_component")
+      .addColumn(analysisUuid)
+      .addColumn(componentUuid)
       .build());
   }
 
index 40c2c55bf55ea1f429f622fdb4f49b083e17ee7a..cc18a42a61dcc92037475bb8095b565cf6372982 100644 (file)
@@ -22,7 +22,9 @@ package org.sonar.db.version.v60;
 import java.sql.SQLException;
 import org.sonar.db.Database;
 import org.sonar.db.version.AlterColumnsBuilder;
+import org.sonar.db.version.CreateIndexBuilder;
 import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.VarcharColumnDef;
 
 import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE;
 import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder;
@@ -37,9 +39,22 @@ public class MakeComponentUuidColumnsNotNullOnSnapshots extends DdlChange {
 
   @Override
   public void execute(Context context) throws SQLException {
+    VarcharColumnDef componentUuid = newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build();
+    VarcharColumnDef rootComponentUuid = newVarcharColumnDefBuilder().setColumnName("root_component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build();
     context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), TABLE_SNAPSHOTS)
-      .updateColumn(newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build())
-      .updateColumn(newVarcharColumnDefBuilder().setColumnName("root_component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build())
+      .updateColumn(componentUuid)
+      .updateColumn(rootComponentUuid)
+      .build());
+
+    context.execute(new CreateIndexBuilder(getDialect())
+      .setTable(TABLE_SNAPSHOTS)
+      .setName("snapshot_component")
+      .addColumn(componentUuid)
+      .build());
+    context.execute(new CreateIndexBuilder(getDialect())
+      .setTable(TABLE_SNAPSHOTS)
+      .setName("snapshot_root_component")
+      .addColumn(rootComponentUuid)
       .build());
   }
 
index 2a6c87a1e2d2a4d376849284e5865278b5130f9c..722e94981891a025db9d57cdfb839ec17488d054 100644 (file)
@@ -22,7 +22,9 @@ package org.sonar.db.version.v60;
 import java.sql.SQLException;
 import org.sonar.db.Database;
 import org.sonar.db.version.AlterColumnsBuilder;
+import org.sonar.db.version.CreateIndexBuilder;
 import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.VarcharColumnDef;
 
 import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE;
 import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder;
@@ -37,9 +39,16 @@ public class MakeUuidColumnsNotNullOnProjects extends DdlChange {
 
   @Override
   public void execute(Context context) throws SQLException {
+    VarcharColumnDef rootUuid = newVarcharColumnDefBuilder().setColumnName("root_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build();
     context.execute(new AlterColumnsBuilder(getDialect(), TABLE_PROJECTS)
       .updateColumn(newVarcharColumnDefBuilder().setColumnName("uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build())
-      .updateColumn(newVarcharColumnDefBuilder().setColumnName("root_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build())
+      .updateColumn(rootUuid)
+      .build());
+
+    context.execute(new CreateIndexBuilder(getDialect())
+      .setTable(TABLE_PROJECTS)
+      .setName("projects_root_uuid")
+      .addColumn(rootUuid)
       .build());
   }
 
index 0124ff4b135f21b6ca27c9005f82b21dc1240462..711a55f6331f2d61c69b40074bd5d80defa3d318 100644 (file)
@@ -22,7 +22,9 @@ package org.sonar.db.version.v60;
 import java.sql.SQLException;
 import org.sonar.db.Database;
 import org.sonar.db.version.AlterColumnsBuilder;
+import org.sonar.db.version.CreateIndexBuilder;
 import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.VarcharColumnDef;
 
 import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE;
 import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder;
@@ -37,10 +39,17 @@ public class MakeUuidColumnsNotNullOnResourceIndex extends DdlChange {
 
   @Override
   public void execute(Context context) throws SQLException {
+    VarcharColumnDef componentUuid = newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build();
     context.execute(new AlterColumnsBuilder(getDialect(), TABLE_RESOURCE_INDEX)
-      .updateColumn(newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build())
+      .updateColumn(componentUuid)
       .updateColumn(newVarcharColumnDefBuilder().setColumnName("root_component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build())
       .build());
+
+    context.execute(new CreateIndexBuilder(getDialect())
+      .setTable(TABLE_RESOURCE_INDEX)
+      .setName("resource_index_component")
+      .addColumn(componentUuid)
+      .build());
   }
 
 }
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/RecreateIndexProjectsUuidFromProjects.java b/sonar-db/src/main/java/org/sonar/db/version/v60/RecreateIndexProjectsUuidFromProjects.java
new file mode 100644 (file)
index 0000000..a617e05
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.CreateIndexBuilder;
+import org.sonar.db.version.DdlChange;
+
+import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder;
+
+public class RecreateIndexProjectsUuidFromProjects extends DdlChange {
+
+  public RecreateIndexProjectsUuidFromProjects(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new CreateIndexBuilder(getDialect())
+      .setTable("projects")
+      .setName("projects_uuid")
+      .addColumn(newVarcharColumnDefBuilder().setColumnName("uuid").setLimit(50).build())
+      .build());
+  }
+}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/TemporarilyDropIndexOfAnalysisUuidOnMeasures.java b/sonar-db/src/main/java/org/sonar/db/version/v60/TemporarilyDropIndexOfAnalysisUuidOnMeasures.java
new file mode 100644 (file)
index 0000000..3e8a614
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.DropIndexBuilder;
+
+/**
+ * the index must be dropped for the compatibility of migration 1270
+ * with MSSQL
+ */
+public class TemporarilyDropIndexOfAnalysisUuidOnMeasures extends DdlChange {
+
+  public TemporarilyDropIndexOfAnalysisUuidOnMeasures(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new DropIndexBuilder(getDialect())
+      .setTable("project_measures")
+      .setName("measures_analysis_metric")
+      .build());
+  }
+}
index bd8a690ead1e25757cb9961d74a85590958a4d03..c9b851e2ec9b256fa70c26cac322749c73fcb73f 100644 (file)
@@ -22,8 +22,10 @@ package org.sonar.db.version.v61;
 import java.sql.SQLException;
 import java.util.List;
 import org.sonar.db.Database;
+import org.sonar.db.version.CreateIndexBuilder;
 import org.sonar.db.version.CreateTableBuilder;
 import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.VarcharColumnDef;
 
 import static org.sonar.db.version.BigIntegerColumnDef.newBigIntegerColumnDefBuilder;
 import static org.sonar.db.version.BooleanColumnDef.newBooleanColumnDefBuilder;
@@ -34,24 +36,34 @@ import static org.sonar.db.version.VarcharColumnDef.MAX_SIZE;
 import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder;
 
 public class CreateTableProperties2 extends DdlChange {
+
+  private static final String TABLE_NAME = "properties2";
+
   public CreateTableProperties2(Database db) {
     super(db);
   }
 
   @Override
   public void execute(Context context) throws SQLException {
-    List<String> stmts = new CreateTableBuilder(getDialect(), "properties2")
-        .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT)
-        .addColumn(newVarcharColumnDefBuilder().setColumnName("prop_key").setLimit(512).setIsNullable(false).build())
-        .addColumn(newBigIntegerColumnDefBuilder().setColumnName("resource_id").setIsNullable(true).build())
-        .addColumn(newBigIntegerColumnDefBuilder().setColumnName("user_id").setIsNullable(true).build())
-        .addColumn(newBooleanColumnDefBuilder().setColumnName("is_empty").setIsNullable(false).build())
-        .addColumn(newVarcharColumnDefBuilder().setColumnName("text_value").setLimit(MAX_SIZE).setIsNullable(true).build())
-        .addColumn(newClobColumnDefBuilder().setColumnName("clob_value").setIsNullable(true).build())
-        .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build())
-        // table with be renamed to properties in following migration, use final constraint name right away
-        .withPkConstraintName("pk_properties")
-        .build();
+    VarcharColumnDef propKey = newVarcharColumnDefBuilder().setColumnName("prop_key").setLimit(512).setIsNullable(false).build();
+    List<String> stmts = new CreateTableBuilder(getDialect(), TABLE_NAME)
+      .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT)
+      .addColumn(propKey)
+      .addColumn(newBigIntegerColumnDefBuilder().setColumnName("resource_id").setIsNullable(true).build())
+      .addColumn(newBigIntegerColumnDefBuilder().setColumnName("user_id").setIsNullable(true).build())
+      .addColumn(newBooleanColumnDefBuilder().setColumnName("is_empty").setIsNullable(false).build())
+      .addColumn(newVarcharColumnDefBuilder().setColumnName("text_value").setLimit(MAX_SIZE).setIsNullable(true).build())
+      .addColumn(newClobColumnDefBuilder().setColumnName("clob_value").setIsNullable(true).build())
+      .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build())
+      // table with be renamed to properties in following migration, use final constraint name right away
+      .withPkConstraintName("pk_properties")
+      .build();
     context.execute(stmts);
+
+    context.execute(new CreateIndexBuilder(getDialect())
+      .setTable(TABLE_NAME)
+      .setName("properties2_key")
+      .addColumn(propKey)
+      .build());
   }
 }
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v61/DropTableActivities.java b/sonar-db/src/main/java/org/sonar/db/version/v61/DropTableActivities.java
new file mode 100644 (file)
index 0000000..8a00977
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.db.version.v61;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.DropIndexBuilder;
+import org.sonar.db.version.DropTableBuilder;
+
+public class DropTableActivities extends DdlChange {
+
+  private static final String TABLE_ACTIVITIES = "activities";
+
+  public DropTableActivities(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new DropIndexBuilder(getDialect())
+      .setTable(TABLE_ACTIVITIES)
+      .setName("activities_log_key")
+      .build());
+
+    context.execute(new DropTableBuilder(getDialect(), TABLE_ACTIVITIES).build());
+  }
+
+}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v61/DropTableProperties.java b/sonar-db/src/main/java/org/sonar/db/version/v61/DropTableProperties.java
new file mode 100644 (file)
index 0000000..32da55d
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.db.version.v61;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.DropIndexBuilder;
+import org.sonar.db.version.DropTableBuilder;
+
+public class DropTableProperties extends DdlChange {
+
+  private static final String TABLE_PROPERTIES = "properties";
+
+  public DropTableProperties(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new DropIndexBuilder(getDialect())
+      .setTable(TABLE_PROPERTIES)
+      .setName("properties_key")
+      .build());
+
+    context.execute(new DropTableBuilder(getDialect(), TABLE_PROPERTIES).build());
+  }
+
+}
index 69047e4ab625c049854f21fa07fcedbbaabd935c..d25a0414ab35a3925b1dd6c6156594979d415983 100644 (file)
@@ -21,24 +21,30 @@ package org.sonar.db.version.v62;
 
 import java.sql.SQLException;
 import org.sonar.db.Database;
+import org.sonar.db.version.CreateIndexBuilder;
 import org.sonar.db.version.CreateTableBuilder;
 import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.VarcharColumnDef;
 
 import static org.sonar.db.version.BigIntegerColumnDef.newBigIntegerColumnDefBuilder;
 import static org.sonar.db.version.VarcharColumnDef.UUID_SIZE;
 import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder;
 
 public class CreateTableOrganizations extends DdlChange {
+
+  private static final String TABLE_NAME = "organizations";
+
   public CreateTableOrganizations(Database db) {
     super(db);
   }
 
   @Override
   public void execute(Context context) throws SQLException {
+    VarcharColumnDef keeColumn = newVarcharColumnDefBuilder().setColumnName("kee").setLimit(32).setIsNullable(false).build();
     context.execute(
-      new CreateTableBuilder(getDialect(), "organizations")
+      new CreateTableBuilder(getDialect(), TABLE_NAME)
         .addPkColumn(newVarcharColumnDefBuilder().setColumnName("uuid").setLimit(UUID_SIZE).setIsNullable(false).build())
-        .addColumn(newVarcharColumnDefBuilder().setColumnName("kee").setLimit(32).setIsNullable(false).build())
+        .addColumn(keeColumn)
         .addColumn(newVarcharColumnDefBuilder().setColumnName("name").setLimit(64).setIsNullable(false).build())
         .addColumn(newVarcharColumnDefBuilder().setColumnName("description").setLimit(256).setIsNullable(true).build())
         .addColumn(newVarcharColumnDefBuilder().setColumnName("url").setLimit(256).setIsNullable(true).build())
@@ -46,5 +52,11 @@ public class CreateTableOrganizations extends DdlChange {
         .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build())
         .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(false).build())
         .build());
+
+    context.execute(new CreateIndexBuilder(getDialect())
+      .setTable(TABLE_NAME)
+      .setName("organization_key")
+      .addColumn(keeColumn)
+      .build());
   }
 }
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v62/IncludeOrganizationUuidInUniqueIndexOfGroupRoles.java b/sonar-db/src/main/java/org/sonar/db/version/v62/IncludeOrganizationUuidInUniqueIndexOfGroupRoles.java
new file mode 100644 (file)
index 0000000..d2413ba
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.db.version.v62;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.CreateIndexBuilder;
+import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.DropIndexBuilder;
+
+import static org.sonar.db.version.IntegerColumnDef.newIntegerColumnDefBuilder;
+import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder;
+
+public class IncludeOrganizationUuidInUniqueIndexOfGroupRoles extends DdlChange {
+
+  private static final String TABLE_GROUP_ROLES = "group_roles";
+
+  public IncludeOrganizationUuidInUniqueIndexOfGroupRoles(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new DropIndexBuilder(getDialect())
+      .setTable(TABLE_GROUP_ROLES)
+      .setName("uniq_group_roles")
+      .build());
+
+    context.execute(new CreateIndexBuilder(getDialect())
+      .setTable(TABLE_GROUP_ROLES)
+      .setName("uniq_group_roles")
+      .setUnique(true)
+      .addColumn(newVarcharColumnDefBuilder().setColumnName("organization_uuid").setLimit(40).build())
+      .addColumn(newIntegerColumnDefBuilder().setColumnName("group_id").build())
+      .addColumn(newIntegerColumnDefBuilder().setColumnName("resource_id").build())
+      .addColumn(newVarcharColumnDefBuilder().setColumnName("role").setLimit(64).build())
+      .build());
+  }
+}
index 43b89391ec6cda2ff4f58882995ce3a57f6695e9..e8e3bc2db471a1ab600e94b1e4759ef0ea79d80a 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-
 package org.sonar.db.version.v63;
 
 import java.sql.SQLException;
 import org.sonar.db.Database;
 import org.sonar.db.version.AlterColumnsBuilder;
+import org.sonar.db.version.CreateIndexBuilder;
 import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.VarcharColumnDef;
 
 import static org.sonar.db.version.VarcharColumnDef.UUID_SIZE;
 import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder;
@@ -38,8 +39,16 @@ public class MakeUuidNotNullOnEvents extends DdlChange {
 
   @Override
   public void execute(Context context) throws SQLException {
+    VarcharColumnDef uuidColumn = newVarcharColumnDefBuilder().setColumnName("uuid").setLimit(UUID_SIZE).setIsNullable(false).build();
     context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), TABLE)
-      .updateColumn(newVarcharColumnDefBuilder().setColumnName("uuid").setLimit(UUID_SIZE).setIsNullable(false).build())
+      .updateColumn(uuidColumn)
+      .build());
+
+    context.execute(new CreateIndexBuilder(getDialect())
+      .setTable(TABLE)
+      .setName("events_uuid")
+      .setUnique(true)
+      .addColumn(uuidColumn)
       .build());
   }
 }
index 02056648d4b3c8cf5416274f302a5b0bd2c5d1f3..615bade9e167ac82f581b3f4e38dc114fc6ed2fb 100644 (file)
@@ -29,6 +29,6 @@ public class MigrationStepModuleTest {
   public void verify_count_of_added_MigrationStep_types() {
     ComponentContainer container = new ComponentContainer();
     new MigrationStepModule().configure(container);
-    assertThat(container.size()).isEqualTo(167);
+    assertThat(container.size()).isEqualTo(187);
   }
 }