]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7786 compress DUPLICATIONS_INDEX migrations
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Fri, 8 Jul 2016 15:31:24 +0000 (17:31 +0200)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Mon, 11 Jul 2016 17:07:36 +0000 (19:07 +0200)
38 files changed:
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1235_add_component_uuid_and_analysis_uuid_to_duplications_index.rb [new file with mode: 0644]
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1235_add_component_uuid_to_duplications_index.rb [deleted file]
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1236_populate_component_uuid_and_analysis_uuid_of_duplications_index.rb [new file with mode: 0644]
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1236_populate_component_uuid_of_duplications_index.rb [deleted file]
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1237_delete_orphan_duplications_index_rows_without_component.rb [deleted file]
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1237_delete_orphan_duplications_index_rows_without_component_or_analysis.rb [new file with mode: 0644]
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1238_make_component_uuid_and_analysis_uuid_not_null_on_duplications_index.rb [new file with mode: 0644]
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1238_make_component_uuid_not_null_on_duplications_index.rb [deleted file]
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1239_add_analysis_uuid_to_duplications_index.rb [deleted file]
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1240_populate_analysis_uuid_of_duplications_index.rb [deleted file]
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1241_delete_orphan_duplications_index_rows_without_analysis.rb [deleted file]
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1242_make_analysis_uuid_not_null_on_duplications_index.rb [deleted file]
sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java
sonar-db/src/main/java/org/sonar/db/version/v60/AddAnalysisUuidColumnToDuplicationsIndex.java [deleted file]
sonar-db/src/main/java/org/sonar/db/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndex.java [new file with mode: 0644]
sonar-db/src/main/java/org/sonar/db/version/v60/AddComponentUuidColumnToDuplicationsIndex.java [deleted file]
sonar-db/src/main/java/org/sonar/db/version/v60/DeleteOrphanDuplicationsIndexRowsWithoutAnalysis.java [deleted file]
sonar-db/src/main/java/org/sonar/db/version/v60/DeleteOrphanDuplicationsIndexRowsWithoutComponent.java [deleted file]
sonar-db/src/main/java/org/sonar/db/version/v60/DeleteOrphanDuplicationsIndexRowsWithoutComponentOrAnalysis.java [new file with mode: 0644]
sonar-db/src/main/java/org/sonar/db/version/v60/MakeAnalysisUuidNotNullOnDuplicationsIndex.java [deleted file]
sonar-db/src/main/java/org/sonar/db/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex.java [new file with mode: 0644]
sonar-db/src/main/java/org/sonar/db/version/v60/MakeComponentUuidNotNullOnDuplicationsIndex.java [deleted file]
sonar-db/src/main/java/org/sonar/db/version/v60/PopulateAnalysisUuidOfDuplicationsIndex.java [deleted file]
sonar-db/src/main/java/org/sonar/db/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex.java [new file with mode: 0644]
sonar-db/src/main/java/org/sonar/db/version/v60/PopulateComponentUuidOfDuplicationsIndex.java [deleted file]
sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java
sonar-db/src/test/java/org/sonar/db/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest.java [new file with mode: 0644]
sonar-db/src/test/java/org/sonar/db/version/v60/AddComponentUuidColumnToDuplicationsIndexTest.java [deleted file]
sonar-db/src/test/java/org/sonar/db/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndexTest.java [new file with mode: 0644]
sonar-db/src/test/java/org/sonar/db/version/v60/MakeComponentUuidNotNullOnDuplicationsIndexTest.java [deleted file]
sonar-db/src/test/java/org/sonar/db/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest.java [new file with mode: 0644]
sonar-db/src/test/java/org/sonar/db/version/v60/PopulateComponentUuidOfDuplicationsIndexTest.java [deleted file]
sonar-db/src/test/resources/org/sonar/db/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest/duplications_index_5.6.sql [new file with mode: 0644]
sonar-db/src/test/resources/org/sonar/db/version/v60/AddComponentUuidColumnToDuplicationsIndexTest/duplications_index_5.6.sql [deleted file]
sonar-db/src/test/resources/org/sonar/db/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndexTest/in_progress_duplications_index.sql [new file with mode: 0644]
sonar-db/src/test/resources/org/sonar/db/version/v60/MakeComponentUuidNotNullOnDuplicationsIndexTest/in_progress_duplications_index.sql [deleted file]
sonar-db/src/test/resources/org/sonar/db/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest/in_progress_measures_with_snapshots.sql [new file with mode: 0644]
sonar-db/src/test/resources/org/sonar/db/version/v60/PopulateComponentUuidOfDuplicationsIndexTest/in_progress_measures_with_snapshots.sql [deleted file]

diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1235_add_component_uuid_and_analysis_uuid_to_duplications_index.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1235_add_component_uuid_and_analysis_uuid_to_duplications_index.rb
new file mode 100644 (file)
index 0000000..6cd915e
--- /dev/null
@@ -0,0 +1,29 @@
+#
+# SonarQube, open source software quality management tool.
+# Copyright (C) 2008-2014 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# SonarQube 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.
+#
+# SonarQube 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.
+#
+
+#
+# SonarQube 6.0
+#
+class AddComponentUuidAndAnalysisUuidToDuplicationsIndex < ActiveRecord::Migration
+
+  def self.up
+    execute_java_migration('org.sonar.db.version.v60.AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndex')
+  end
+end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1235_add_component_uuid_to_duplications_index.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1235_add_component_uuid_to_duplications_index.rb
deleted file mode 100644 (file)
index 0631d12..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# SonarQube, open source software quality management tool.
-# Copyright (C) 2008-2014 SonarSource
-# mailto:contact AT sonarsource DOT com
-#
-# SonarQube 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.
-#
-# SonarQube 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.
-#
-
-#
-# SonarQube 6.0
-#
-class AddComponentUuidToDuplicationsIndex < ActiveRecord::Migration
-
-  def self.up
-    execute_java_migration('org.sonar.db.version.v60.AddComponentUuidColumnToDuplicationsIndex')
-  end
-end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1236_populate_component_uuid_and_analysis_uuid_of_duplications_index.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1236_populate_component_uuid_and_analysis_uuid_of_duplications_index.rb
new file mode 100644 (file)
index 0000000..4e30c48
--- /dev/null
@@ -0,0 +1,29 @@
+#
+# SonarQube, open source software quality management tool.
+# Copyright (C) 2008-2014 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# SonarQube 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.
+#
+# SonarQube 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.
+#
+
+#
+# SonarQube 6.0
+#
+class PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex < ActiveRecord::Migration
+
+  def self.up
+    execute_java_migration('org.sonar.db.version.v60.PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex')
+  end
+end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1236_populate_component_uuid_of_duplications_index.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1236_populate_component_uuid_of_duplications_index.rb
deleted file mode 100644 (file)
index 28a53ab..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# SonarQube, open source software quality management tool.
-# Copyright (C) 2008-2014 SonarSource
-# mailto:contact AT sonarsource DOT com
-#
-# SonarQube 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.
-#
-# SonarQube 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.
-#
-
-#
-# SonarQube 6.0
-#
-class PopulateComponentUuidOfDuplicationsIndex < ActiveRecord::Migration
-
-  def self.up
-    execute_java_migration('org.sonar.db.version.v60.PopulateComponentUuidOfDuplicationsIndex')
-  end
-end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1237_delete_orphan_duplications_index_rows_without_component.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1237_delete_orphan_duplications_index_rows_without_component.rb
deleted file mode 100644 (file)
index 1d78fcb..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# SonarQube, open source software quality management tool.
-# Copyright (C) 2008-2014 SonarSource
-# mailto:contact AT sonarsource DOT com
-#
-# SonarQube 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.
-#
-# SonarQube 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.
-#
-
-#
-# SonarQube 6.0
-#
-class DeleteOrphanDuplicationsIndexRowsWithoutComponent < ActiveRecord::Migration
-
-  def self.up
-    execute_java_migration('org.sonar.db.version.v60.DeleteOrphanDuplicationsIndexRowsWithoutComponent')
-  end
-end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1237_delete_orphan_duplications_index_rows_without_component_or_analysis.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1237_delete_orphan_duplications_index_rows_without_component_or_analysis.rb
new file mode 100644 (file)
index 0000000..a869ada
--- /dev/null
@@ -0,0 +1,29 @@
+#
+# SonarQube, open source software quality management tool.
+# Copyright (C) 2008-2014 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# SonarQube 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.
+#
+# SonarQube 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.
+#
+
+#
+# SonarQube 6.0
+#
+class DeleteOrphanDuplicationsIndexRowsWithoutComponentOrAnalysis < ActiveRecord::Migration
+
+  def self.up
+    execute_java_migration('org.sonar.db.version.v60.DeleteOrphanDuplicationsIndexRowsWithoutComponentOrAnalysis')
+  end
+end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1238_make_component_uuid_and_analysis_uuid_not_null_on_duplications_index.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1238_make_component_uuid_and_analysis_uuid_not_null_on_duplications_index.rb
new file mode 100644 (file)
index 0000000..ff6268c
--- /dev/null
@@ -0,0 +1,31 @@
+#
+# SonarQube, open source software quality management tool.
+# Copyright (C) 2008-2014 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# SonarQube 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.
+#
+# SonarQube 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.
+#
+
+#
+# SonarQube 6.0
+#
+class MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex < ActiveRecord::Migration
+
+  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
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1238_make_component_uuid_not_null_on_duplications_index.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1238_make_component_uuid_not_null_on_duplications_index.rb
deleted file mode 100644 (file)
index a9c235b..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# SonarQube, open source software quality management tool.
-# Copyright (C) 2008-2014 SonarSource
-# mailto:contact AT sonarsource DOT com
-#
-# SonarQube 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.
-#
-# SonarQube 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.
-#
-
-#
-# SonarQube 6.0
-#
-class MakeComponentUuidNotNullOnDuplicationsIndex < ActiveRecord::Migration
-
-  def self.up
-    execute_java_migration('org.sonar.db.version.v60.MakeComponentUuidNotNullOnDuplicationsIndex')
-  end
-end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1239_add_analysis_uuid_to_duplications_index.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1239_add_analysis_uuid_to_duplications_index.rb
deleted file mode 100644 (file)
index a3154d5..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# SonarQube, open source software quality management tool.
-# Copyright (C) 2008-2014 SonarSource
-# mailto:contact AT sonarsource DOT com
-#
-# SonarQube 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.
-#
-# SonarQube 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.
-#
-
-#
-# SonarQube 6.0
-#
-class AddAnalysisUuidToDuplicationsIndex < ActiveRecord::Migration
-
-  def self.up
-    execute_java_migration('org.sonar.db.version.v60.AddAnalysisUuidColumnToDuplicationsIndex')
-  end
-end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1240_populate_analysis_uuid_of_duplications_index.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1240_populate_analysis_uuid_of_duplications_index.rb
deleted file mode 100644 (file)
index b760ef1..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# SonarQube, open source software quality management tool.
-# Copyright (C) 2008-2014 SonarSource
-# mailto:contact AT sonarsource DOT com
-#
-# SonarQube 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.
-#
-# SonarQube 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.
-#
-
-#
-# SonarQube 6.0
-#
-class PopulateAnalysisUuidOfDuplicationsIndex < ActiveRecord::Migration
-
-  def self.up
-    execute_java_migration('org.sonar.db.version.v60.PopulateAnalysisUuidOfDuplicationsIndex')
-  end
-end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1241_delete_orphan_duplications_index_rows_without_analysis.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1241_delete_orphan_duplications_index_rows_without_analysis.rb
deleted file mode 100644 (file)
index cf42ef8..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# SonarQube, open source software quality management tool.
-# Copyright (C) 2008-2014 SonarSource
-# mailto:contact AT sonarsource DOT com
-#
-# SonarQube 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.
-#
-# SonarQube 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.
-#
-
-#
-# SonarQube 6.0
-#
-class DeleteOrphanDuplicationsIndexRowsWithoutAnalysis < ActiveRecord::Migration
-
-  def self.up
-    execute_java_migration('org.sonar.db.version.v60.DeleteOrphanDuplicationsIndexRowsWithoutAnalysis')
-  end
-end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1242_make_analysis_uuid_not_null_on_duplications_index.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1242_make_analysis_uuid_not_null_on_duplications_index.rb
deleted file mode 100644 (file)
index dfb335e..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# SonarQube, open source software quality management tool.
-# Copyright (C) 2008-2014 SonarSource
-# mailto:contact AT sonarsource DOT com
-#
-# SonarQube 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.
-#
-# SonarQube 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.
-#
-
-#
-# SonarQube 6.0
-#
-class MakeAnalysisUuidNotNullOnDuplicationsIndex < ActiveRecord::Migration
-
-  def self.up
-    execute_java_migration('org.sonar.db.version.v60.MakeAnalysisUuidNotNullOnDuplicationsIndex')
-
-    add_index :duplications_index, [:analysis_uuid, :component_uuid], :name => 'duplication_analysis_component'
-  end
-end
index 72d947d5e85733aca058b8fd2d0e5a274c0a3431..2c3be5b7f11e1feaa8ac9c9247a56db141f1a35f 100644 (file)
@@ -84,11 +84,10 @@ 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.v60.AddAnalysisUuidColumnToCeActivity;
-import org.sonar.db.version.v60.AddAnalysisUuidColumnToDuplicationsIndex;
 import org.sonar.db.version.v60.AddAnalysisUuidColumnToEvents;
 import org.sonar.db.version.v60.AddAnalysisUuidColumnToMeasures;
 import org.sonar.db.version.v60.AddBColumnsToProjects;
-import org.sonar.db.version.v60.AddComponentUuidColumnToDuplicationsIndex;
+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.AddLastUsedColumnToRulesProfiles;
@@ -105,8 +104,7 @@ 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.DeleteOrphanDuplicationsIndexRowsWithoutAnalysis;
-import org.sonar.db.version.v60.DeleteOrphanDuplicationsIndexRowsWithoutComponent;
+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;
@@ -121,11 +119,10 @@ import org.sonar.db.version.v60.DropTreeColumnsFromSnapshots;
 import org.sonar.db.version.v60.DropTreesOfSnapshots;
 import org.sonar.db.version.v60.DropUnusedMeasuresColumns;
 import org.sonar.db.version.v60.FixProjectUuidOfDeveloperProjects;
-import org.sonar.db.version.v60.MakeAnalysisUuidNotNullOnDuplicationsIndex;
 import org.sonar.db.version.v60.MakeAnalysisUuidNotNullOnEvents;
 import org.sonar.db.version.v60.MakeAnalysisUuidNotNullOnMeasures;
+import org.sonar.db.version.v60.MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex;
 import org.sonar.db.version.v60.MakeComponentUuidColumnsNotNullOnSnapshots;
-import org.sonar.db.version.v60.MakeComponentUuidNotNullOnDuplicationsIndex;
 import org.sonar.db.version.v60.MakeComponentUuidNotNullOnMeasures;
 import org.sonar.db.version.v60.MakeProfileKeyNotNullOnActivities;
 import org.sonar.db.version.v60.MakeUuidColumnNotNullOnSnapshots;
@@ -133,11 +130,10 @@ import org.sonar.db.version.v60.MakeUuidColumnsNotNullOnProjects;
 import org.sonar.db.version.v60.MakeUuidColumnsNotNullOnResourceIndex;
 import org.sonar.db.version.v60.MakeUuidPathColumnNotNullOnProjects;
 import org.sonar.db.version.v60.PopulateAnalysisUuidColumnOnCeActivity;
-import org.sonar.db.version.v60.PopulateAnalysisUuidOfDuplicationsIndex;
 import org.sonar.db.version.v60.PopulateAnalysisUuidOnEvents;
 import org.sonar.db.version.v60.PopulateAnalysisUuidOnMeasures;
+import org.sonar.db.version.v60.PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex;
 import org.sonar.db.version.v60.PopulateComponentUuidColumnsOfSnapshots;
-import org.sonar.db.version.v60.PopulateComponentUuidOfDuplicationsIndex;
 import org.sonar.db.version.v60.PopulateComponentUuidOfMeasures;
 import org.sonar.db.version.v60.PopulateLastUsedColumnOfRulesProfiles;
 import org.sonar.db.version.v60.PopulateProfileKeyOfActivities;
@@ -273,16 +269,10 @@ public class MigrationStepModule extends Module {
       DropSnapshotIdColumnFromCeActivity.class,
 
       // UUID columns of DUPLICATION_INDEX
-      AddComponentUuidColumnToDuplicationsIndex.class,
-      PopulateComponentUuidOfDuplicationsIndex.class,
-      DeleteOrphanDuplicationsIndexRowsWithoutComponent.class,
-      MakeComponentUuidNotNullOnDuplicationsIndex.class,
-
-      // analysis_uuid in duplications_index
-      AddAnalysisUuidColumnToDuplicationsIndex.class,
-      PopulateAnalysisUuidOfDuplicationsIndex.class,
-      DeleteOrphanDuplicationsIndexRowsWithoutAnalysis.class,
-      MakeAnalysisUuidNotNullOnDuplicationsIndex.class,
+      AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndex.class,
+      PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex.class,
+      DeleteOrphanDuplicationsIndexRowsWithoutComponentOrAnalysis.class,
+      MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex.class,
       DropSnapshotIdColumnsFromDuplicationsIndex.class,
 
       // EVENTS.ANALYSIS_UUID
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/AddAnalysisUuidColumnToDuplicationsIndex.java b/sonar-db/src/main/java/org/sonar/db/version/v60/AddAnalysisUuidColumnToDuplicationsIndex.java
deleted file mode 100644 (file)
index c4c47ef..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.AddColumnsBuilder;
-import org.sonar.db.version.DdlChange;
-
-import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE;
-import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder;
-
-public class AddAnalysisUuidColumnToDuplicationsIndex extends DdlChange {
-
-  private static final String TABLE_DUPLICATIONS_INDEX = "duplications_index";
-
-  public AddAnalysisUuidColumnToDuplicationsIndex(Database db) {
-    super(db);
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    context.execute(new AddColumnsBuilder(getDatabase().getDialect(), TABLE_DUPLICATIONS_INDEX)
-      .addColumn(newVarcharColumnDefBuilder().setColumnName("analysis_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(true).build())
-      .build());
-  }
-
-}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndex.java b/sonar-db/src/main/java/org/sonar/db/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndex.java
new file mode 100644 (file)
index 0000000..f421c12
--- /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.AddColumnsBuilder;
+import org.sonar.db.version.DdlChange;
+
+import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE;
+import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder;
+
+public class AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndex extends DdlChange {
+
+  private static final String TABLE_PUBLICATIONS_INDEX = "duplications_index";
+
+  public AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndex(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new AddColumnsBuilder(getDatabase().getDialect(), TABLE_PUBLICATIONS_INDEX)
+      .addColumn(newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(true).build())
+      .addColumn(newVarcharColumnDefBuilder().setColumnName("analysis_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(true).build())
+      .build());
+  }
+
+}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/AddComponentUuidColumnToDuplicationsIndex.java b/sonar-db/src/main/java/org/sonar/db/version/v60/AddComponentUuidColumnToDuplicationsIndex.java
deleted file mode 100644 (file)
index 62c3b75..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.AddColumnsBuilder;
-import org.sonar.db.version.DdlChange;
-
-import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE;
-import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder;
-
-public class AddComponentUuidColumnToDuplicationsIndex extends DdlChange {
-
-  private static final String TABLE_PUBLICATIONS_INDEX = "duplications_index";
-
-  public AddComponentUuidColumnToDuplicationsIndex(Database db) {
-    super(db);
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    context.execute(new AddColumnsBuilder(getDatabase().getDialect(), TABLE_PUBLICATIONS_INDEX)
-      .addColumn(newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(true).build())
-      .build());
-  }
-
-}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/DeleteOrphanDuplicationsIndexRowsWithoutAnalysis.java b/sonar-db/src/main/java/org/sonar/db/version/v60/DeleteOrphanDuplicationsIndexRowsWithoutAnalysis.java
deleted file mode 100644 (file)
index ae7858c..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.BaseDataChange;
-import org.sonar.db.version.MassUpdate;
-
-public class DeleteOrphanDuplicationsIndexRowsWithoutAnalysis extends BaseDataChange {
-
-  public DeleteOrphanDuplicationsIndexRowsWithoutAnalysis(Database db) {
-    super(db);
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    MassUpdate massUpdate = context.prepareMassUpdate();
-    massUpdate.select("SELECT distinct project_snapshot_id from duplications_index where analysis_uuid is null");
-    massUpdate.update("DELETE from duplications_index WHERE project_snapshot_id=?");
-    massUpdate.rowPluralName("no analysis duplication index entries");
-    massUpdate.execute((row, update) -> {
-      update.setLong(1, row.getLong(1));
-      return true;
-    });
-  }
-
-}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/DeleteOrphanDuplicationsIndexRowsWithoutComponent.java b/sonar-db/src/main/java/org/sonar/db/version/v60/DeleteOrphanDuplicationsIndexRowsWithoutComponent.java
deleted file mode 100644 (file)
index b04cf1b..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.BaseDataChange;
-import org.sonar.db.version.MassUpdate;
-
-public class DeleteOrphanDuplicationsIndexRowsWithoutComponent extends BaseDataChange {
-
-  public DeleteOrphanDuplicationsIndexRowsWithoutComponent(Database db) {
-    super(db);
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    MassUpdate massUpdate = context.prepareMassUpdate();
-    massUpdate.select("SELECT id from duplications_index where component_uuid is null");
-    massUpdate.update("DELETE from duplications_index WHERE id=?");
-    massUpdate.rowPluralName("resources_index entries");
-    massUpdate.execute((row, update) -> {
-      update.setLong(1, row.getLong(1));
-      return true;
-    });
-  }
-
-}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/DeleteOrphanDuplicationsIndexRowsWithoutComponentOrAnalysis.java b/sonar-db/src/main/java/org/sonar/db/version/v60/DeleteOrphanDuplicationsIndexRowsWithoutComponentOrAnalysis.java
new file mode 100644 (file)
index 0000000..9372208
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * 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.BaseDataChange;
+import org.sonar.db.version.MassUpdate;
+
+public class DeleteOrphanDuplicationsIndexRowsWithoutComponentOrAnalysis extends BaseDataChange {
+
+  public DeleteOrphanDuplicationsIndexRowsWithoutComponentOrAnalysis(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    deleteRowsWithoutComponentUuid(context);
+    deleteRowsWithoutAnalysisUuid(context);
+  }
+
+  private static void deleteRowsWithoutComponentUuid(Context context) throws SQLException {
+    MassUpdate massUpdate = context.prepareMassUpdate();
+    massUpdate.select("SELECT id from duplications_index where component_uuid is null");
+    massUpdate.update("DELETE from duplications_index WHERE id=?");
+    massUpdate.rowPluralName("duplications index rows without component");
+    massUpdate.execute((row, update) -> {
+      update.setLong(1, row.getLong(1));
+      return true;
+    });
+  }
+
+  private static void deleteRowsWithoutAnalysisUuid(Context context) throws SQLException {
+    MassUpdate massUpdate = context.prepareMassUpdate();
+    massUpdate.select("SELECT distinct project_snapshot_id from duplications_index where analysis_uuid is null");
+    massUpdate.update("DELETE from duplications_index WHERE project_snapshot_id=?");
+    massUpdate.rowPluralName("duplications index rows without analysis");
+    massUpdate.execute((row, update) -> {
+      update.setLong(1, row.getLong(1));
+      return true;
+    });
+  }
+
+}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/MakeAnalysisUuidNotNullOnDuplicationsIndex.java b/sonar-db/src/main/java/org/sonar/db/version/v60/MakeAnalysisUuidNotNullOnDuplicationsIndex.java
deleted file mode 100644 (file)
index 2de7e96..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.AlterColumnsBuilder;
-import org.sonar.db.version.DdlChange;
-
-import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE;
-import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder;
-
-public class MakeAnalysisUuidNotNullOnDuplicationsIndex extends DdlChange {
-
-  private static final String TABLE_DUPLICATIONS_INDEX = "duplications_index";
-
-  public MakeAnalysisUuidNotNullOnDuplicationsIndex(Database db) {
-    super(db);
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), TABLE_DUPLICATIONS_INDEX)
-      .updateColumn(newVarcharColumnDefBuilder().setColumnName("analysis_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build())
-      .build());
-  }
-
-}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex.java b/sonar-db/src/main/java/org/sonar/db/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex.java
new file mode 100644 (file)
index 0000000..8d48663
--- /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.AlterColumnsBuilder;
+import org.sonar.db.version.DdlChange;
+
+import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE;
+import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder;
+
+public class MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex extends DdlChange {
+
+  private static final String TABLE_DUPLICATIONS_INDEX = "duplications_index";
+
+  public MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    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())
+      .build());
+  }
+
+}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/MakeComponentUuidNotNullOnDuplicationsIndex.java b/sonar-db/src/main/java/org/sonar/db/version/v60/MakeComponentUuidNotNullOnDuplicationsIndex.java
deleted file mode 100644 (file)
index 6198db9..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.AlterColumnsBuilder;
-import org.sonar.db.version.DdlChange;
-
-import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE;
-import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder;
-
-public class MakeComponentUuidNotNullOnDuplicationsIndex extends DdlChange {
-
-  private static final String TABLE_DUPLICATIONS_INDEX = "duplications_index";
-
-  public MakeComponentUuidNotNullOnDuplicationsIndex(Database db) {
-    super(db);
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), TABLE_DUPLICATIONS_INDEX)
-      .updateColumn(newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build())
-      .build());
-  }
-
-}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/PopulateAnalysisUuidOfDuplicationsIndex.java b/sonar-db/src/main/java/org/sonar/db/version/v60/PopulateAnalysisUuidOfDuplicationsIndex.java
deleted file mode 100644 (file)
index e3df430..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.BaseDataChange;
-import org.sonar.db.version.MassUpdate;
-import org.sonar.db.version.Select;
-import org.sonar.db.version.SqlStatement;
-
-public class PopulateAnalysisUuidOfDuplicationsIndex extends BaseDataChange {
-
-  public PopulateAnalysisUuidOfDuplicationsIndex(Database db) {
-    super(db);
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    MassUpdate massUpdate = context.prepareMassUpdate();
-    massUpdate.select("select distinct di.project_snapshot_id, s.uuid from duplications_index di" +
-      " inner join snapshots s on s.id=di.project_snapshot_id" +
-      " where di.analysis_uuid is null");
-    massUpdate.update("UPDATE duplications_index SET analysis_uuid=? WHERE project_snapshot_id=? and analysis_uuid is null");
-    massUpdate.rowPluralName("analysis uuid of duplications_index entries");
-    massUpdate.execute(PopulateAnalysisUuidOfDuplicationsIndex::handle);
-  }
-
-  public static boolean handle(Select.Row row, SqlStatement update) throws SQLException {
-    long projectSnapshotId = row.getLong(1);
-    String snapshotUuid = row.getString(2);
-
-    update.setString(1, snapshotUuid);
-    update.setLong(2, projectSnapshotId);
-
-    return true;
-  }
-
-}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex.java b/sonar-db/src/main/java/org/sonar/db/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex.java
new file mode 100644 (file)
index 0000000..dc26fdd
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * 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.BaseDataChange;
+import org.sonar.db.version.MassUpdate;
+import org.sonar.db.version.Select;
+import org.sonar.db.version.SqlStatement;
+
+public class PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex extends BaseDataChange {
+
+  public PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    populateComponentUuid(context);
+    populateAnalysisUuid(context);
+  }
+
+  private void populateComponentUuid(Context context) throws SQLException {
+    MassUpdate massUpdate = context.prepareMassUpdate();
+    massUpdate.select("select distinct di.snapshot_id, s.component_uuid from duplications_index di" +
+      " inner join snapshots s on s.id=di.snapshot_id" +
+      " where di.component_uuid is null");
+    massUpdate.update("UPDATE duplications_index SET component_uuid=? WHERE snapshot_id=? and component_uuid is null");
+    massUpdate.rowPluralName("component uuid of duplications_index entries");
+    massUpdate.execute(PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex::handleComponentUuid);
+  }
+
+  private static boolean handleComponentUuid(Select.Row row, SqlStatement update) throws SQLException {
+    long snapshotId = row.getLong(1);
+    String componentUuid = row.getString(2);
+
+    update.setString(1, componentUuid);
+    update.setLong(2, snapshotId);
+
+    return true;
+  }
+  
+  public void populateAnalysisUuid(Context context) throws SQLException {
+    MassUpdate massUpdate = context.prepareMassUpdate();
+    massUpdate.select("select distinct di.project_snapshot_id, s.uuid from duplications_index di" +
+        " inner join snapshots s on s.id=di.project_snapshot_id" +
+        " where di.analysis_uuid is null");
+    massUpdate.update("UPDATE duplications_index SET analysis_uuid=? WHERE project_snapshot_id=? and analysis_uuid is null");
+    massUpdate.rowPluralName("analysis uuid of duplications_index entries");
+    massUpdate.execute(PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex::handleAnalysisUuid);
+  }
+
+  private static boolean handleAnalysisUuid(Select.Row row, SqlStatement update) throws SQLException {
+    long projectSnapshotId = row.getLong(1);
+    String snapshotUuid = row.getString(2);
+
+    update.setString(1, snapshotUuid);
+    update.setLong(2, projectSnapshotId);
+
+    return true;
+  }
+
+}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/PopulateComponentUuidOfDuplicationsIndex.java b/sonar-db/src/main/java/org/sonar/db/version/v60/PopulateComponentUuidOfDuplicationsIndex.java
deleted file mode 100644 (file)
index a5f433d..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.BaseDataChange;
-import org.sonar.db.version.MassUpdate;
-import org.sonar.db.version.Select;
-import org.sonar.db.version.SqlStatement;
-
-public class PopulateComponentUuidOfDuplicationsIndex extends BaseDataChange {
-
-  public PopulateComponentUuidOfDuplicationsIndex(Database db) {
-    super(db);
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    MassUpdate massUpdate = context.prepareMassUpdate();
-    massUpdate.select("select distinct di.snapshot_id, s.component_uuid from duplications_index di" +
-      " inner join snapshots s on s.id=di.snapshot_id" +
-      " where di.component_uuid is null");
-    massUpdate.update("UPDATE duplications_index SET component_uuid=? WHERE snapshot_id=? and component_uuid is null");
-    massUpdate.rowPluralName("component uuid of duplications_index entries");
-    massUpdate.execute(PopulateComponentUuidOfDuplicationsIndex::handle);
-  }
-
-  public static boolean handle(Select.Row row, SqlStatement update) throws SQLException {
-    long snapshotId = row.getLong(1);
-    String componentUuid = row.getString(2);
-
-    update.setString(1, componentUuid);
-    update.setLong(2, snapshotId);
-
-    return true;
-  }
-
-}
index cd190a68543c02d614e080375726ed6c5e3cc58c..b10eba51a6fa01fa447a4b78dff5b43122d8619d 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(129);
+    assertThat(container.size()).isEqualTo(125);
   }
 }
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest.java b/sonar-db/src/test/java/org/sonar/db/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest.java
new file mode 100644 (file)
index 0000000..fa75f76
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * 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 java.sql.Types;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.sonar.api.utils.System2;
+import org.sonar.db.DbTester;
+
+import static java.lang.String.valueOf;
+
+public class AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest {
+
+  private static final String TABLE = "duplications_index";
+
+  @Rule
+  public DbTester db = DbTester.createForSchema(System2.INSTANCE, AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest.class,
+    "duplications_index_5.6.sql");
+  @Rule
+  public ExpectedException expectedException = ExpectedException.none();
+
+  private AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndex underTest = new AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndex(db.database());
+
+  @Test
+  public void migration_adds_column_to_empty_table() throws SQLException {
+    underTest.execute();
+
+    verifyAddedColumns();
+  }
+
+  @Test
+  public void migration_adds_column_to_populated_table() throws SQLException {
+    for (int i = 0; i < 9; i++) {
+      db.executeInsert(
+        TABLE,
+        "ID", valueOf(i),
+        "PROJECT_SNAPSHOT_ID", valueOf(10 + i),
+        "SNAPSHOT_ID", valueOf(20 + i),
+        "HASH", "some_hash_" + i,
+        "INDEX_IN_FILE", "2",
+        "START_LINE", "3",
+        "END_LINE", "4");
+    }
+    db.commit();
+
+    underTest.execute();
+
+    verifyAddedColumns();
+  }
+
+  @Test
+  public void migration_is_not_reentrant() throws SQLException {
+    underTest.execute();
+
+    expectedException.expect(IllegalStateException.class);
+    expectedException.expectMessage("Fail to execute ");
+    underTest.execute();
+  }
+
+  private void verifyAddedColumns() {
+    db.assertColumnDefinition(TABLE, "component_uuid", Types.VARCHAR, 50, true);
+    db.assertColumnDefinition(TABLE, "analysis_uuid", Types.VARCHAR, 50, true);
+  }
+
+}
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v60/AddComponentUuidColumnToDuplicationsIndexTest.java b/sonar-db/src/test/java/org/sonar/db/version/v60/AddComponentUuidColumnToDuplicationsIndexTest.java
deleted file mode 100644 (file)
index 4ba3a65..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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 static java.lang.String.valueOf;
-
-import java.sql.SQLException;
-import java.sql.Types;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
-
-public class AddComponentUuidColumnToDuplicationsIndexTest {
-
-  private static final String TABLE = "duplications_index";
-
-  @Rule
-  public DbTester db = DbTester.createForSchema(System2.INSTANCE, AddComponentUuidColumnToDuplicationsIndexTest.class,
-    "duplications_index_5.6.sql");
-  @Rule
-  public ExpectedException expectedException = ExpectedException.none();
-
-  private AddComponentUuidColumnToDuplicationsIndex underTest = new AddComponentUuidColumnToDuplicationsIndex(db.database());
-
-  @Test
-  public void migration_adds_column_to_empty_table() throws SQLException {
-    underTest.execute();
-
-    verifyAddedColumns();
-  }
-
-  @Test
-  public void migration_adds_column_to_populated_table() throws SQLException {
-    for (int i = 0; i < 9; i++) {
-      db.executeInsert(
-        TABLE,
-        "ID", valueOf(i),
-        "PROJECT_SNAPSHOT_ID", valueOf(10 + i),
-        "SNAPSHOT_ID", valueOf(20 + i),
-        "HASH", "some_hash_" + i,
-        "INDEX_IN_FILE", "2",
-        "START_LINE", "3",
-        "END_LINE", "4");
-    }
-    db.commit();
-
-    underTest.execute();
-
-    verifyAddedColumns();
-  }
-
-  @Test
-  public void migration_is_not_reentrant() throws SQLException {
-    underTest.execute();
-
-    expectedException.expect(IllegalStateException.class);
-    expectedException.expectMessage("Fail to execute ");
-    underTest.execute();
-  }
-
-  private void verifyAddedColumns() {
-    db.assertColumnDefinition(TABLE, "component_uuid", Types.VARCHAR, 50, true);
-  }
-
-}
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndexTest.java b/sonar-db/src/test/java/org/sonar/db/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndexTest.java
new file mode 100644 (file)
index 0000000..203c2f5
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * 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 java.sql.Types;
+import java.util.List;
+import java.util.stream.Collectors;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.sonar.api.utils.System2;
+import org.sonar.db.DbTester;
+
+import static java.lang.String.valueOf;
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndexTest {
+
+  @Rule
+  public DbTester db = DbTester.createForSchema(System2.INSTANCE, MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndexTest.class,
+    "in_progress_duplications_index.sql");
+  @Rule
+  public ExpectedException expectedException = ExpectedException.none();
+
+  private MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex underTest = new MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex(db.database());
+
+  @Test
+  public void migration_sets_uuid_columns_not_nullable_on_empty_table() throws SQLException {
+    underTest.execute();
+
+    verifyColumnDefinitions();
+  }
+
+  @Test
+  public void migration_sets_uuid_columns_not_nullable_on_populated_table() throws SQLException {
+    insertDuplicationIndex(1L, true, true);
+    insertDuplicationIndex(2L, true, true);
+
+    underTest.execute();
+
+    verifyColumnDefinitions();
+    assertThat(idsOfRowsInDuplicationsIndex()).containsOnly(1L, 2L);
+  }
+
+  @Test
+  public void migration_fails_if_some_component_uuid_columns_are_null() throws SQLException {
+    insertDuplicationIndex(1L, false, true);
+
+    expectedException.expect(IllegalStateException.class);
+    expectedException.expectMessage("Fail to execute");
+
+    underTest.execute();
+  }
+
+  @Test
+  public void migration_fails_if_some_analysis_uuid_columns_are_null() throws SQLException {
+    insertDuplicationIndex(1L, true, false);
+
+    expectedException.expect(IllegalStateException.class);
+    expectedException.expectMessage("Fail to execute");
+
+    underTest.execute();
+  }
+
+  private void verifyColumnDefinitions() {
+    db.assertColumnDefinition("duplications_index", "component_uuid", Types.VARCHAR, 50, false);
+    db.assertColumnDefinition("duplications_index", "analysis_uuid", Types.VARCHAR, 50, false);
+  }
+
+  private List<Long> idsOfRowsInDuplicationsIndex() {
+    return db.select("select ID from duplications_index").stream().map(map -> (Long) map.get("ID")).collect(Collectors.toList());
+  }
+
+  private void insertDuplicationIndex(long id, boolean hasComponentUuid, boolean hasAnalysisUuid) {
+    db.executeInsert(
+      "duplications_index",
+      "ID", valueOf(id),
+      "PROJECT_SNAPSHOT_ID", valueOf(10 + id),
+      "SNAPSHOT_ID", valueOf(20 + id),
+        "ANALYSIS_UUID", hasAnalysisUuid ? valueOf(30 + id) : null,
+        "COMPONENT_UUID", hasComponentUuid ? valueOf(40 + id) : null,
+        "HASH", "some_hash_" + id,
+      "INDEX_IN_FILE", "2",
+      "START_LINE", "3",
+      "END_LINE", "4");
+  }
+
+}
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v60/MakeComponentUuidNotNullOnDuplicationsIndexTest.java b/sonar-db/src/test/java/org/sonar/db/version/v60/MakeComponentUuidNotNullOnDuplicationsIndexTest.java
deleted file mode 100644 (file)
index ec32c46..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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 java.sql.Types;
-import java.util.List;
-import java.util.stream.Collectors;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
-
-import static java.lang.String.valueOf;
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class MakeComponentUuidNotNullOnDuplicationsIndexTest {
-
-  @Rule
-  public DbTester db = DbTester.createForSchema(System2.INSTANCE, MakeComponentUuidNotNullOnDuplicationsIndexTest.class,
-    "in_progress_duplications_index.sql");
-  @Rule
-  public ExpectedException expectedException = ExpectedException.none();
-
-  private MakeComponentUuidNotNullOnDuplicationsIndex underTest = new MakeComponentUuidNotNullOnDuplicationsIndex(db.database());
-
-  @Test
-  public void migration_sets_uuid_columns_not_nullable_on_empty_table() throws SQLException {
-    underTest.execute();
-
-    verifyColumnDefinitions();
-  }
-
-  @Test
-  public void migration_sets_uuid_columns_not_nullable_on_populated_table() throws SQLException {
-    insertDuplicationIndex(1L, true);
-    insertDuplicationIndex(2L, true);
-
-    underTest.execute();
-
-    verifyColumnDefinitions();
-    assertThat(idsOfRowsInDuplicationsIndex()).containsOnly(1L, 2L);
-  }
-
-  @Test
-  public void migration_fails_if_some_uuid_columns_are_null() throws SQLException {
-    insertDuplicationIndex(1L, false);
-
-    expectedException.expect(IllegalStateException.class);
-    expectedException.expectMessage("Fail to execute");
-
-    underTest.execute();
-  }
-
-  private void verifyColumnDefinitions() {
-    db.assertColumnDefinition("duplications_index", "component_uuid", Types.VARCHAR, 50, false);
-  }
-
-  private List<Long> idsOfRowsInDuplicationsIndex() {
-    return db.select("select ID from duplications_index").stream().map(map -> (Long) map.get("ID")).collect(Collectors.toList());
-  }
-
-  private void insertDuplicationIndex(long id, boolean hasComponentUuid) {
-    db.executeInsert(
-      "duplications_index",
-      "ID", valueOf(id),
-      "PROJECT_SNAPSHOT_ID", valueOf(10 + id),
-      "SNAPSHOT_ID", valueOf(20 + id),
-      "COMPONENT_UUID", hasComponentUuid ? valueOf(30 + id) : null,
-      "HASH", "some_hash_" + id,
-      "INDEX_IN_FILE", "2",
-      "START_LINE", "3",
-      "END_LINE", "4");
-  }
-
-}
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest.java b/sonar-db/src/test/java/org/sonar/db/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest.java
new file mode 100644 (file)
index 0000000..33ec71b
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+ * 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 java.util.List;
+import java.util.Map;
+import javax.annotation.Nullable;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.api.utils.System2;
+import org.sonar.db.DbTester;
+
+import static java.lang.String.valueOf;
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest {
+
+  @Rule
+  public DbTester db = DbTester.createForSchema(System2.INSTANCE, PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest.class,
+    "in_progress_measures_with_snapshots.sql");
+
+  private PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex underTest = new PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex(db.database());
+
+  @Test
+  public void migration_has_no_effect_on_empty_tables() throws SQLException {
+    underTest.execute();
+
+    assertThat(db.countRowsOfTable("duplications_index")).isEqualTo(0);
+    assertThat(db.countRowsOfTable("snapshots")).isEqualTo(0);
+  }
+
+  @Test
+  public void migration_updates_component_uuid_with_values_from_table_snapshots_when_they_exist() throws SQLException {
+    insertSnapshot(40, "cpt1");
+    String rootUuid1 = insertSnapshot(50, "cpt2");
+    insertSnapshot(60, "cpt3");
+    String rootUuid2 = insertSnapshot(70, "cpt4");
+
+    insertDuplicationIndex(1, 40, 50);
+    insertDuplicationIndex(2, 40, 50);
+    insertDuplicationIndex(3, 40, 70);
+    insertDuplicationIndex(4, 60, 110); // 110 doesn't exist
+    insertDuplicationIndex(5, 90, 120); // 90 and 120 does not exist
+    insertDuplicationIndex(6, 100, 70); // 100 does not exist
+    db.commit();
+
+    underTest.execute();
+
+    verifyDuplicationsIndex(1, 40, "cpt1", rootUuid1);
+    verifyDuplicationsIndex(2, 40, "cpt1", rootUuid1);
+    verifyDuplicationsIndex(3, 40, "cpt1", rootUuid2);
+    verifyDuplicationsIndex(4, 60, "cpt3", null);
+    verifyDuplicationsIndex(5, 90, null, null);
+    verifyDuplicationsIndex(6, 100, null, rootUuid2);
+  }
+
+  @Test
+  public void migration_is_reentrant() throws SQLException {
+    insertSnapshot(40, "cpt1");
+    String rootUuid = insertSnapshot(50, "cp2");
+    insertDuplicationIndex(1, 40, 50);
+
+    underTest.execute();
+    verifyDuplicationsIndex(1, 40, "cpt1", rootUuid);
+
+    underTest.execute();
+    verifyDuplicationsIndex(1, 40, "cpt1", rootUuid);
+
+  }
+
+  private void verifyDuplicationsIndex(long id, long snapshotId, @Nullable String componentUuid, @Nullable String analysisUuid) {
+    List<Map<String, Object>> rows = db.select("select SNAPSHOT_ID, COMPONENT_UUID,ANALYSIS_UUID from duplications_index where ID=" + id);
+    assertThat(rows).hasSize(1);
+    Map<String, Object> row = rows.get(0);
+    assertThat(row.get("SNAPSHOT_ID")).isEqualTo(snapshotId);
+    assertThat(row.get("COMPONENT_UUID")).isEqualTo(componentUuid);
+    assertThat(row.get("ANALYSIS_UUID")).isEqualTo(analysisUuid);
+  }
+
+  private String insertSnapshot(long id, String componentUuid) {
+    String uuid = "uuid_" + id;
+    db.executeInsert(
+      "snapshots",
+      "uuid", uuid,
+      "id", valueOf(id),
+      "component_uuid", componentUuid,
+      "root_component_uuid", valueOf(id + 100));
+    return uuid;
+  }
+
+  private void insertDuplicationIndex(long id, long snapshotId, long projectSnapshotId) {
+    db.executeInsert(
+      "duplications_index",
+      "ID", valueOf(id),
+      "PROJECT_SNAPSHOT_ID", valueOf(projectSnapshotId),
+      "SNAPSHOT_ID", valueOf(snapshotId),
+      "HASH", "some_hash_" + id,
+      "INDEX_IN_FILE", "2",
+      "START_LINE", "3",
+      "END_LINE", "4");
+  }
+
+}
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v60/PopulateComponentUuidOfDuplicationsIndexTest.java b/sonar-db/src/test/java/org/sonar/db/version/v60/PopulateComponentUuidOfDuplicationsIndexTest.java
deleted file mode 100644 (file)
index acd4a75..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * 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 java.util.List;
-import java.util.Map;
-import javax.annotation.Nullable;
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
-
-import static java.lang.String.valueOf;
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class PopulateComponentUuidOfDuplicationsIndexTest {
-
-  @Rule
-  public DbTester db = DbTester.createForSchema(System2.INSTANCE, PopulateComponentUuidOfDuplicationsIndexTest.class,
-    "in_progress_measures_with_snapshots.sql");
-
-  private PopulateComponentUuidOfDuplicationsIndex underTest = new PopulateComponentUuidOfDuplicationsIndex(db.database());
-
-  @Test
-  public void migration_has_no_effect_on_empty_tables() throws SQLException {
-    underTest.execute();
-
-    assertThat(db.countRowsOfTable("duplications_index")).isEqualTo(0);
-    assertThat(db.countRowsOfTable("snapshots")).isEqualTo(0);
-  }
-
-  @Test
-  public void migration_updates_component_uuid_with_values_from_table_snapshots_when_they_exist() throws SQLException {
-    String uuid1 = insertSnapshot(40);
-    insertSnapshot(50);
-    String uuid3 = insertSnapshot(60);
-    insertSnapshot(70);
-
-    insertDuplicationIndex(1, 40);
-    insertDuplicationIndex(2, 40);
-    insertDuplicationIndex(3, 40);
-    insertDuplicationIndex(4, 60);
-    insertDuplicationIndex(5, 90); // 90 does not exist
-    insertDuplicationIndex(6, 100); // 100 does not exist
-    db.commit();
-
-    underTest.execute();
-
-    verifyDuplicationsIndex(1, 40, uuid1);
-    verifyDuplicationsIndex(2, 40, uuid1);
-    verifyDuplicationsIndex(3, 40, uuid1);
-    verifyDuplicationsIndex(4, 60, uuid3);
-    verifyDuplicationsIndex(5, 90, null);
-    verifyDuplicationsIndex(6, 100, null);
-  }
-
-  @Test
-  public void migration_is_reentrant() throws SQLException {
-    String uuid1 = insertSnapshot(40);
-    insertSnapshot(50);
-    insertDuplicationIndex(1, 40);
-
-    underTest.execute();
-    verifyDuplicationsIndex(1, 40, uuid1);
-
-    underTest.execute();
-    verifyDuplicationsIndex(1, 40, uuid1);
-
-  }
-
-  private void verifyDuplicationsIndex(long id, long snapshotId, @Nullable String componentUuid) {
-    List<Map<String, Object>> rows = db.select("select SNAPSHOT_ID, COMPONENT_UUID from duplications_index where ID=" + id);
-    assertThat(rows).hasSize(1);
-    Map<String, Object> row = rows.get(0);
-    assertThat(row.get("SNAPSHOT_ID")).isEqualTo(snapshotId);
-    assertThat(row.get("COMPONENT_UUID")).isEqualTo(componentUuid);
-  }
-
-  private String insertSnapshot(long id) {
-    String uuid = "uuid_" + id;
-    db.executeInsert(
-      "snapshots",
-      "id", valueOf(id),
-      "component_uuid", uuid,
-      "root_component_uuid", valueOf(id + 100));
-    return uuid;
-  }
-
-  private void insertDuplicationIndex(long id, long snapshotId) {
-    db.executeInsert(
-      "duplications_index",
-      "ID", valueOf(id),
-      "PROJECT_SNAPSHOT_ID", valueOf(10 + id),
-      "SNAPSHOT_ID", valueOf(snapshotId),
-      "HASH", "some_hash_" + id,
-      "INDEX_IN_FILE", "2",
-      "START_LINE", "3",
-      "END_LINE", "4");
-  }
-
-}
diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest/duplications_index_5.6.sql b/sonar-db/src/test/resources/org/sonar/db/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest/duplications_index_5.6.sql
new file mode 100644 (file)
index 0000000..6ac3885
--- /dev/null
@@ -0,0 +1,9 @@
+CREATE TABLE "DUPLICATIONS_INDEX" (
+  "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+  "PROJECT_SNAPSHOT_ID" INTEGER NOT NULL,
+  "SNAPSHOT_ID" INTEGER NOT NULL,
+  "HASH" VARCHAR(50) NOT NULL,
+  "INDEX_IN_FILE" INTEGER NOT NULL,
+  "START_LINE" INTEGER NOT NULL,
+  "END_LINE" INTEGER NOT NULL
+);
diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v60/AddComponentUuidColumnToDuplicationsIndexTest/duplications_index_5.6.sql b/sonar-db/src/test/resources/org/sonar/db/version/v60/AddComponentUuidColumnToDuplicationsIndexTest/duplications_index_5.6.sql
deleted file mode 100644 (file)
index 6ac3885..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-CREATE TABLE "DUPLICATIONS_INDEX" (
-  "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
-  "PROJECT_SNAPSHOT_ID" INTEGER NOT NULL,
-  "SNAPSHOT_ID" INTEGER NOT NULL,
-  "HASH" VARCHAR(50) NOT NULL,
-  "INDEX_IN_FILE" INTEGER NOT NULL,
-  "START_LINE" INTEGER NOT NULL,
-  "END_LINE" INTEGER NOT NULL
-);
diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndexTest/in_progress_duplications_index.sql b/sonar-db/src/test/resources/org/sonar/db/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndexTest/in_progress_duplications_index.sql
new file mode 100644 (file)
index 0000000..5bd4e10
--- /dev/null
@@ -0,0 +1,11 @@
+CREATE TABLE "DUPLICATIONS_INDEX" (
+  "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+  "PROJECT_SNAPSHOT_ID" INTEGER NOT NULL,
+  "SNAPSHOT_ID" INTEGER NOT NULL,
+  "ANALYSIS_UUID" VARCHAR(50),
+  "COMPONENT_UUID" VARCHAR(50),
+  "HASH" VARCHAR(50) NOT NULL,
+  "INDEX_IN_FILE" INTEGER NOT NULL,
+  "START_LINE" INTEGER NOT NULL,
+  "END_LINE" INTEGER NOT NULL
+);
diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v60/MakeComponentUuidNotNullOnDuplicationsIndexTest/in_progress_duplications_index.sql b/sonar-db/src/test/resources/org/sonar/db/version/v60/MakeComponentUuidNotNullOnDuplicationsIndexTest/in_progress_duplications_index.sql
deleted file mode 100644 (file)
index df0cc07..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-CREATE TABLE "DUPLICATIONS_INDEX" (
-  "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
-  "PROJECT_SNAPSHOT_ID" INTEGER NOT NULL,
-  "SNAPSHOT_ID" INTEGER NOT NULL,
-  "COMPONENT_UUID" VARCHAR(50),
-  "HASH" VARCHAR(50) NOT NULL,
-  "INDEX_IN_FILE" INTEGER NOT NULL,
-  "START_LINE" INTEGER NOT NULL,
-  "END_LINE" INTEGER NOT NULL
-);
diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest/in_progress_measures_with_snapshots.sql b/sonar-db/src/test/resources/org/sonar/db/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest/in_progress_measures_with_snapshots.sql
new file mode 100644 (file)
index 0000000..526a759
--- /dev/null
@@ -0,0 +1,45 @@
+CREATE TABLE "DUPLICATIONS_INDEX" (
+  "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+  "PROJECT_SNAPSHOT_ID" INTEGER NOT NULL,
+  "SNAPSHOT_ID" INTEGER NOT NULL,
+  "ANALYSIS_UUID" VARCHAR(50),
+  "COMPONENT_UUID" VARCHAR(50),
+  "HASH" VARCHAR(50) NOT NULL,
+  "INDEX_IN_FILE" INTEGER NOT NULL,
+  "START_LINE" INTEGER NOT NULL,
+  "END_LINE" INTEGER NOT NULL
+);
+
+CREATE TABLE "SNAPSHOTS" (
+  "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+  "UUID" VARCHAR(50) NOT NULL,
+  "CREATED_AT" BIGINT,
+  "BUILD_DATE" BIGINT,
+  "COMPONENT_UUID" VARCHAR(50) NOT NULL,
+  "PARENT_SNAPSHOT_ID" INTEGER,
+  "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U',
+  "PURGE_STATUS" INTEGER,
+  "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE,
+  "SCOPE" VARCHAR(3),
+  "QUALIFIER" VARCHAR(10),
+  "ROOT_SNAPSHOT_ID" INTEGER,
+  "VERSION" VARCHAR(500),
+  "PATH" VARCHAR(500),
+  "DEPTH" INTEGER,
+  "ROOT_COMPONENT_UUID" VARCHAR(50) NOT NULL,
+  "PERIOD1_MODE" VARCHAR(100),
+  "PERIOD1_PARAM" VARCHAR(100),
+  "PERIOD1_DATE" BIGINT,
+  "PERIOD2_MODE" VARCHAR(100),
+  "PERIOD2_PARAM" VARCHAR(100),
+  "PERIOD2_DATE" BIGINT,
+  "PERIOD3_MODE" VARCHAR(100),
+  "PERIOD3_PARAM" VARCHAR(100),
+  "PERIOD3_DATE" BIGINT,
+  "PERIOD4_MODE" VARCHAR(100),
+  "PERIOD4_PARAM" VARCHAR(100),
+  "PERIOD4_DATE" BIGINT,
+  "PERIOD5_MODE" VARCHAR(100),
+  "PERIOD5_PARAM" VARCHAR(100),
+  "PERIOD5_DATE" BIGINT
+);
diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v60/PopulateComponentUuidOfDuplicationsIndexTest/in_progress_measures_with_snapshots.sql b/sonar-db/src/test/resources/org/sonar/db/version/v60/PopulateComponentUuidOfDuplicationsIndexTest/in_progress_measures_with_snapshots.sql
deleted file mode 100644 (file)
index 94a2041..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-CREATE TABLE "DUPLICATIONS_INDEX" (
-  "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
-  "PROJECT_SNAPSHOT_ID" INTEGER NOT NULL,
-  "SNAPSHOT_ID" INTEGER NOT NULL,
-  "COMPONENT_UUID" VARCHAR(50),
-  "HASH" VARCHAR(50) NOT NULL,
-  "INDEX_IN_FILE" INTEGER NOT NULL,
-  "START_LINE" INTEGER NOT NULL,
-  "END_LINE" INTEGER NOT NULL
-);
-
-CREATE TABLE "SNAPSHOTS" (
-  "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
-  "CREATED_AT" BIGINT,
-  "BUILD_DATE" BIGINT,
-  "COMPONENT_UUID" VARCHAR(50) NOT NULL,
-  "PARENT_SNAPSHOT_ID" INTEGER,
-  "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U',
-  "PURGE_STATUS" INTEGER,
-  "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE,
-  "SCOPE" VARCHAR(3),
-  "QUALIFIER" VARCHAR(10),
-  "ROOT_SNAPSHOT_ID" INTEGER,
-  "VERSION" VARCHAR(500),
-  "PATH" VARCHAR(500),
-  "DEPTH" INTEGER,
-  "ROOT_COMPONENT_UUID" VARCHAR(50) NOT NULL,
-  "PERIOD1_MODE" VARCHAR(100),
-  "PERIOD1_PARAM" VARCHAR(100),
-  "PERIOD1_DATE" BIGINT,
-  "PERIOD2_MODE" VARCHAR(100),
-  "PERIOD2_PARAM" VARCHAR(100),
-  "PERIOD2_DATE" BIGINT,
-  "PERIOD3_MODE" VARCHAR(100),
-  "PERIOD3_PARAM" VARCHAR(100),
-  "PERIOD3_DATE" BIGINT,
-  "PERIOD4_MODE" VARCHAR(100),
-  "PERIOD4_PARAM" VARCHAR(100),
-  "PERIOD4_DATE" BIGINT,
-  "PERIOD5_MODE" VARCHAR(100),
-  "PERIOD5_PARAM" VARCHAR(100),
-  "PERIOD5_DATE" BIGINT
-);