]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6366 rename DatabaseMigration to MigrationStep
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Thu, 16 Apr 2015 14:27:25 +0000 (16:27 +0200)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Fri, 17 Apr 2015 13:15:00 +0000 (15:15 +0200)
also rename DatabaseMigrations to MigrationSteps
this is required to to make room for the more appropriatly named DatabaseMigration class that deals with triggering the database migration

161 files changed:
server/sonar-server/src/main/java/org/sonar/server/db/migrations/AddColumnsBuilder.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/BaseDataChange.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/BaseSqlStatement.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/DataChange.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/DatabaseMigration.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/DatabaseMigrations.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/DatabaseMigrator.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/DdlChange.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/DropColumnsBuilder.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/MassUpdate.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/MigrationStep.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/MigrationSteps.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/Select.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/SelectImpl.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/SqlStatement.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/SqlUtil.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/UpsertImpl.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v36/Progress.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v36/Referentials.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v36/ViolationConverter.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v36/ViolationConverters.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v36/ViolationMigration.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v36/ViolationMigrationStep.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v42/CompleteIssueMessageMigration.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v42/CompleteIssueMessageMigrationStep.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v42/PackageKeysMigration.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v42/PackageKeysMigrationStep.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/ConvertIssueDebtToMinutesMigration.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/ConvertIssueDebtToMinutesMigrationStep.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/DevelopmentCostMeasuresMigration.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/DevelopmentCostMeasuresMigrationStep.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/IssueChangelogMigration.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/IssueChangelogMigrationStep.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/NotResolvedIssuesOnRemovedComponentsMigration.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/NotResolvedIssuesOnRemovedComponentsMigrationStep.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/RequirementMeasuresMigration.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/RequirementMeasuresMigrationStep.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/TechnicalDebtMeasuresMigration.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/TechnicalDebtMeasuresMigrationStep.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/WorkDurationConvertor.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/ChangeLogMigration.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/ChangeLogMigrationStep.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/ConvertProfileMeasuresMigration.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/ConvertProfileMeasuresMigrationStep.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/FeedQProfileDatesMigration.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/FeedQProfileDatesMigrationStep.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/FeedQProfileKeysMigration.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/FeedQProfileKeysMigrationStep.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/IssueActionPlanKeyMigration.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/IssueActionPlanKeyMigrationStep.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/MeasureDataMigration.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/MeasureDataMigrationStep.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v45/AddMissingRuleParameterDefaultValuesMigration.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v45/AddMissingRuleParameterDefaultValuesMigrationStep.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v45/DeleteMeasuresOnDeletedProfilesMigration.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v45/DeleteMeasuresOnDeletedProfilesMigrationStep.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v451/AddMissingCustomRuleParametersMigration.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v451/AddMissingCustomRuleParametersMigrationStep.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v451/DeleteUnescapedActivities.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/FeedFileSources.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/FeedIssueLongDates.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/FeedSnapshotSourcesUpdatedAt.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/FileSourceDto.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/InsertProjectsAuthorizationUpdatedAtMigration.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/InsertProjectsAuthorizationUpdatedAtMigrationStep.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigration.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationStep.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/RemoveSortFieldFromIssueFiltersMigration.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/RemoveSortFieldFromIssueFiltersMigrationStep.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/ReplaceIssueFiltersProjectKeyByUuid.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v51/AddIssuesColumns.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v51/AddNewCharacteristics.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v51/CopyScmAccountsFromAuthorsToUsers.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v51/DropIssuesColumns.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v51/FeedAnalysisReportsLongDates.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v51/FeedEventsLongDates.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v51/FeedFileSourcesBinaryData.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v51/FeedIssueChangesLongDates.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v51/FeedIssueComponentUuids.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v51/FeedIssueTags.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v51/FeedIssuesLongDates.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v51/FeedManualMeasuresLongDates.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v51/FeedSemaphoresLongDates.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v51/FeedSnapshotsLongDates.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v51/FeedUsersLongDates.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v51/RemovePermissionsOnModulesMigration.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v51/RemovePermissionsOnModulesMigrationStep.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v51/RenameComponentRelatedParamsInIssueFilters.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v51/UpdateProjectsModuleUuidPath.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v52/FeedEventsComponentUuid.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v52/FeedProjectLinksComponentUuid.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v52/MoveProjectProfileAssociation.java
server/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/DatabaseMigrationsTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/db/migrations/DatabaseMigratorTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/MigrationStepsTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v36/ViolationMigrationTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v42/CompleteIssueMessageMigrationTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v42/PackageKeysMigrationTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v43/ConvertIssueDebtToMinutesMigrationTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v43/DevelopmentCostMeasuresMigrationTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v43/IssueChangelogMigrationTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v43/NotResolvedIssuesOnRemovedComponentsMigrationTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v43/RequirementMeasuresMigrationTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v43/TechnicalDebtMeasuresMigrationTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v44/ChangeLogMigrationTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v44/ConvertProfileMeasuresMigrationTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v44/FeedQProfileDatesMigrationTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v44/FeedQProfileKeysMigrationTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v44/IssueActionPlanKeyMigrationTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v44/MeasureDataMigrationTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v45/AddMissingRuleParameterDefaultValuesMigrationTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v45/DeleteMeasuresOnDeletedProfilesMigrationTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v451/AddMissingCustomRuleParametersMigrationTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v451/DeleteUnescapedActivitiesTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v50/FeedIssueLongDatesTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v50/InsertProjectsAuthorizationUpdatedAtMigrationTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v50/RemoveSortFieldFromIssueFiltersMigrationTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v50/ReplaceIssueFiltersProjectKeyByUuidTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v51/AddIssuesColumnsTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v51/CopyScmAccountsFromAuthorsToUsersTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v51/FeedAnalysisReportsLongDatesTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v51/FeedEventsLongDatesTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v51/FeedFileSourcesBinaryDataTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v51/FeedIssueChangesLongDatesTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v51/FeedIssuesLongDatesTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v51/FeedManualMeasuresLongDatesTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v51/FeedSemaphoresLongDatesTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v51/FeedSnapshotsLongDatesTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v51/FeedUsersLongDatesTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v51/RemovePermissionsOnModulesMigrationTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v51/RenameComponentRelatedParamsInIssueFiltersMigrationTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v51/UpdateProjectsModuleUuidPathTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v52/FeedEventsComponentUuidTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v52/FeedProjectLinksComponentUuidTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v52/MoveProjectProfileAssociationTest.java
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/401_migrate_violations_to_issues.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/490_migrate_package_keys.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/497_update_issue_message_by_rule_name_when_no_message.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/513_convert_issue_debt_to_minutes.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/514_update_issue_changelog_debt_to_minutes.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/515_update_measures_debt_to_minutes.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/516_update_development_cost_to_minutes.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/521_update_requirement_measures.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/525_update_not_resolved_issues_on_removed_components.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/530_merge_measure_data_into_project_measures.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/531_update_issues_action_plan_key_on_removed_action_plan.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/549_feed_qprofile_keys.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/550_convert_profile_measures.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/551_update_logs_to_activities.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/553_feed_qprofile_dates.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/583_add_missing_rule_parameter_default_values.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/584_delete_measures_on_deleted_profiles.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/601_add_missing_custom_rule_parameters.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/705_populate_projects_uuid_columns.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/716_insert_projects_authorization_updated_at.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/721_remove_sort_field_from_issue_filters.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/795_remove_permissions_on_modules.rb
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/README.txt

index 34aca9d0e41c5a8b99be2a92fcc08377039d7ceb..4010c94067e52e6c7213ef24a1755242e4a5d7d0 100644 (file)
  */
 package org.sonar.server.db.migrations;
 
-import com.google.common.base.CharMatcher;
-import com.google.common.base.Preconditions;
-import org.sonar.core.persistence.dialect.Dialect;
-import org.sonar.core.persistence.dialect.MsSql;
-import org.sonar.core.persistence.dialect.Oracle;
-import org.sonar.core.persistence.dialect.PostgreSql;
+import static com.google.common.collect.Lists.newArrayList;
+
+import java.util.List;
 
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
 
-import java.util.List;
+import org.sonar.core.persistence.dialect.Dialect;
+import org.sonar.core.persistence.dialect.MsSql;
+import org.sonar.core.persistence.dialect.Oracle;
+import org.sonar.core.persistence.dialect.PostgreSql;
 
-import static com.google.common.collect.Lists.newArrayList;
+import com.google.common.base.CharMatcher;
+import com.google.common.base.Preconditions;
 
 public class AddColumnsBuilder {
 
index b90886eb3f4e034778d69677c562a3599fe6f56a..0631b2e1cf23522cc7b98baafc0d4250cf71ab3f 100644 (file)
  */
 package org.sonar.server.db.migrations;
 
-import org.apache.commons.dbutils.DbUtils;
-import org.sonar.core.persistence.Database;
-
 import java.sql.Connection;
 import java.sql.SQLException;
 
-public abstract class BaseDataChange implements DataChange, DatabaseMigration {
+import org.apache.commons.dbutils.DbUtils;
+import org.sonar.core.persistence.Database;
+
+public abstract class BaseDataChange implements DataChange, MigrationStep {
 
   private final Database db;
 
index e4416b9401d4d216e33bc66abf31b19676cff21b..8983e7ecb5c8b891859a02d64c16cd3eacae4061 100644 (file)
  */
 package org.sonar.server.db.migrations;
 
-import org.apache.commons.dbutils.DbUtils;
-
-import javax.annotation.Nullable;
-
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
 import java.sql.Timestamp;
 import java.sql.Types;
 import java.util.Date;
 
+import javax.annotation.Nullable;
+
+import org.apache.commons.dbutils.DbUtils;
+
 class BaseSqlStatement<CHILD extends SqlStatement> implements SqlStatement<CHILD> {
   protected PreparedStatement pstmt;
 
index c901a7825948a05494c75739aa17c23959259ea5..8b513ffcd2e9b51632731f5c5348b60af8bf7821 100644 (file)
  */
 package org.sonar.server.db.migrations;
 
-import org.sonar.core.persistence.Database;
-
 import java.sql.Connection;
 import java.sql.SQLException;
 
+import org.sonar.core.persistence.Database;
+
 public interface DataChange {
 
   class Context {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/DatabaseMigration.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/DatabaseMigration.java
deleted file mode 100644 (file)
index b20a35c..0000000
+++ /dev/null
@@ -1,32 +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.
- */
-package org.sonar.server.db.migrations;
-
-import java.sql.SQLException;
-
-/**
- * Java alternative of ActiveRecord::Migration. Do not forget to declare implementation classes in {@link DatabaseMigrations#CLASSES}
- * @since 3.7
- */
-public interface DatabaseMigration {
-
-  void execute() throws SQLException;
-
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/DatabaseMigrations.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/DatabaseMigrations.java
deleted file mode 100644 (file)
index 96411ab..0000000
+++ /dev/null
@@ -1,107 +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.
- */
-package org.sonar.server.db.migrations;
-
-import com.google.common.collect.ImmutableList;
-import org.sonar.server.db.migrations.v36.ViolationMigration;
-import org.sonar.server.db.migrations.v42.CompleteIssueMessageMigration;
-import org.sonar.server.db.migrations.v42.PackageKeysMigration;
-import org.sonar.server.db.migrations.v43.*;
-import org.sonar.server.db.migrations.v44.*;
-import org.sonar.server.db.migrations.v45.AddMissingRuleParameterDefaultValuesMigration;
-import org.sonar.server.db.migrations.v45.DeleteMeasuresOnDeletedProfilesMigration;
-import org.sonar.server.db.migrations.v451.AddMissingCustomRuleParametersMigration;
-import org.sonar.server.db.migrations.v451.DeleteUnescapedActivities;
-import org.sonar.server.db.migrations.v50.*;
-import org.sonar.server.db.migrations.v51.*;
-import org.sonar.server.db.migrations.v52.FeedEventsComponentUuid;
-import org.sonar.server.db.migrations.v52.FeedProjectLinksComponentUuid;
-import org.sonar.server.db.migrations.v52.MoveProjectProfileAssociation;
-
-import java.util.List;
-
-public interface DatabaseMigrations {
-
-  List<Class<? extends DatabaseMigration>> CLASSES = ImmutableList.of(
-    // 3.6
-    ViolationMigration.class,
-
-    // 4.2
-    PackageKeysMigration.class, CompleteIssueMessageMigration.class,
-
-    // 4.3
-    ConvertIssueDebtToMinutesMigration.class,
-    IssueChangelogMigration.class,
-    TechnicalDebtMeasuresMigration.class,
-    DevelopmentCostMeasuresMigration.class,
-    RequirementMeasuresMigration.class,
-    NotResolvedIssuesOnRemovedComponentsMigration.class,
-
-    // 4.4
-    IssueActionPlanKeyMigration.class,
-    MeasureDataMigration.class,
-    FeedQProfileKeysMigration.class,
-    FeedQProfileDatesMigration.class,
-    ChangeLogMigration.class,
-    ConvertProfileMeasuresMigration.class,
-
-    // 4.5
-    AddMissingRuleParameterDefaultValuesMigration.class,
-    DeleteMeasuresOnDeletedProfilesMigration.class,
-
-    // 4.5.1
-    AddMissingCustomRuleParametersMigration.class,
-    DeleteUnescapedActivities.class,
-
-    // 5.0
-    InsertProjectsAuthorizationUpdatedAtMigration.class,
-    PopulateProjectsUuidColumnsMigration.class,
-    ReplaceIssueFiltersProjectKeyByUuid.class,
-    FeedSnapshotSourcesUpdatedAt.class,
-    FeedFileSources.class,
-    FeedIssueLongDates.class,
-    RemoveSortFieldFromIssueFiltersMigration.class,
-
-    // 5.1
-    FeedIssueTags.class,
-    FeedUsersLongDates.class,
-    RenameComponentRelatedParamsInIssueFilters.class,
-    CopyScmAccountsFromAuthorsToUsers.class,
-    FeedIssueChangesLongDates.class,
-    FeedAnalysisReportsLongDates.class,
-    UpdateProjectsModuleUuidPath.class,
-    FeedIssueComponentUuids.class,
-    FeedSnapshotsLongDates.class,
-    FeedIssuesLongDates.class,
-    FeedFileSourcesBinaryData.class,
-    FeedSemaphoresLongDates.class,
-    FeedManualMeasuresLongDates.class,
-    FeedEventsLongDates.class,
-    AddNewCharacteristics.class,
-    RemovePermissionsOnModulesMigration.class,
-    AddIssuesColumns.class,
-    DropIssuesColumns.class,
-
-    // 5.2
-    FeedProjectLinksComponentUuid.class,
-    FeedEventsComponentUuid.class,
-    MoveProjectProfileAssociation.class
-    );
-}
index e13c246802d289eea4e95c2b99b819412aed556c..b506fc5244a2e4b847706c9beda1bc6295c6c3ab 100644 (file)
  */
 package org.sonar.server.db.migrations;
 
-import com.google.common.annotations.VisibleForTesting;
+import java.sql.Connection;
+
 import org.apache.commons.dbutils.DbUtils;
 import org.apache.ibatis.session.SqlSession;
 import org.picocontainer.Startable;
-import org.sonar.api.utils.log.Loggers;
 import org.sonar.api.ServerComponent;
 import org.sonar.api.platform.ServerUpgradeStatus;
+import org.sonar.api.utils.log.Loggers;
 import org.sonar.core.persistence.DdlUtils;
 import org.sonar.server.db.DbClient;
 import org.sonar.server.plugins.ServerPluginRepository;
 
-import java.sql.Connection;
+import com.google.common.annotations.VisibleForTesting;
 
 /**
  * Restore schema by executing DDL scripts. Only H2 database is supported.
@@ -41,14 +42,14 @@ import java.sql.Connection;
 public class DatabaseMigrator implements ServerComponent, Startable {
 
   private final DbClient dbClient;
-  private final DatabaseMigration[] migrations;
+  private final MigrationStep[] migrations;
   private final ServerUpgradeStatus serverUpgradeStatus;
 
   /**
    * ServerPluginRepository is used to ensure H2 schema creation is done only after copy of bundle plugins have been done
    */
-  public DatabaseMigrator(DbClient dbClient, DatabaseMigration[] migrations, ServerUpgradeStatus serverUpgradeStatus,
-                          ServerPluginRepository serverPluginRepository) {
+  public DatabaseMigrator(DbClient dbClient, MigrationStep[] migrations, ServerUpgradeStatus serverUpgradeStatus,
+    ServerPluginRepository serverPluginRepository) {
     this.dbClient = dbClient;
     this.migrations = migrations;
     this.serverUpgradeStatus = serverUpgradeStatus;
@@ -89,7 +90,7 @@ public class DatabaseMigrator implements ServerComponent, Startable {
   }
 
   public void executeMigration(String className) {
-    DatabaseMigration migration = getMigration(className);
+    MigrationStep migration = getMigration(className);
     try {
       migration.execute();
 
@@ -101,8 +102,8 @@ public class DatabaseMigrator implements ServerComponent, Startable {
     }
   }
 
-  private DatabaseMigration getMigration(String className) {
-    for (DatabaseMigration migration : migrations) {
+  private MigrationStep getMigration(String className) {
+    for (MigrationStep migration : migrations) {
       if (migration.getClass().getName().equals(className)) {
         return migration;
       }
index 39944bae8e744382da80878728b93059c39ad049..00320c1a3fe13f565f999ca120e597b6bea9f02b 100644 (file)
  */
 package org.sonar.server.db.migrations;
 
-import org.apache.commons.dbutils.DbUtils;
-import org.sonar.core.persistence.Database;
-
 import java.sql.Connection;
 import java.sql.SQLException;
 
-public abstract class DdlChange implements DatabaseMigration {
+import org.apache.commons.dbutils.DbUtils;
+import org.sonar.core.persistence.Database;
+
+public abstract class DdlChange implements MigrationStep {
 
   private final Database db;
 
index ce61d645b162e1f7f6b8c6c66a47278a8d83260e..a0a2ee1d2c69daa3ecd0bfd07567816d54dc4d42 100644 (file)
  */
 package org.sonar.server.db.migrations;
 
-import org.sonar.core.persistence.dialect.*;
+import org.sonar.core.persistence.dialect.Dialect;
+import org.sonar.core.persistence.dialect.MsSql;
+import org.sonar.core.persistence.dialect.MySql;
+import org.sonar.core.persistence.dialect.Oracle;
+import org.sonar.core.persistence.dialect.PostgreSql;
 
 public class DropColumnsBuilder {
 
index 4c2594dd49607963c8cc8a5c66abd0f21bada4f9..c670ae5333db7581eb9c8e96e7e4fd1fd89e4c23 100644 (file)
  */
 package org.sonar.server.db.migrations;
 
-import org.sonar.core.persistence.Database;
-import org.sonar.server.util.ProgressLogger;
-
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.util.concurrent.atomic.AtomicLong;
 
+import org.sonar.core.persistence.Database;
+import org.sonar.server.util.ProgressLogger;
+
 public class MassUpdate {
 
   public static interface Handler {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/MigrationStep.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/MigrationStep.java
new file mode 100644 (file)
index 0000000..eddf124
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+package org.sonar.server.db.migrations;
+
+import java.sql.SQLException;
+
+/**
+ * Java alternative of ActiveRecord::Migration. Do not forget to declare implementation classes in {@link MigrationSteps#CLASSES}
+ * @since 3.7
+ */
+public interface MigrationStep {
+
+  void execute() throws SQLException;
+
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/MigrationSteps.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/MigrationSteps.java
new file mode 100644 (file)
index 0000000..2944902
--- /dev/null
@@ -0,0 +1,140 @@
+/*
+ * 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.
+ */
+package org.sonar.server.db.migrations;
+
+import com.google.common.collect.ImmutableList;
+import org.sonar.server.db.migrations.v36.ViolationMigrationStep;
+import org.sonar.server.db.migrations.v42.CompleteIssueMessageMigrationStep;
+import org.sonar.server.db.migrations.v42.PackageKeysMigrationStep;
+import org.sonar.server.db.migrations.v43.ConvertIssueDebtToMinutesMigrationStep;
+import org.sonar.server.db.migrations.v43.DevelopmentCostMeasuresMigrationStep;
+import org.sonar.server.db.migrations.v43.IssueChangelogMigrationStep;
+import org.sonar.server.db.migrations.v43.NotResolvedIssuesOnRemovedComponentsMigrationStep;
+import org.sonar.server.db.migrations.v43.RequirementMeasuresMigrationStep;
+import org.sonar.server.db.migrations.v43.TechnicalDebtMeasuresMigrationStep;
+import org.sonar.server.db.migrations.v44.ChangeLogMigrationStep;
+import org.sonar.server.db.migrations.v44.ConvertProfileMeasuresMigrationStep;
+import org.sonar.server.db.migrations.v44.FeedQProfileDatesMigrationStep;
+import org.sonar.server.db.migrations.v44.FeedQProfileKeysMigrationStep;
+import org.sonar.server.db.migrations.v44.IssueActionPlanKeyMigrationStep;
+import org.sonar.server.db.migrations.v44.MeasureDataMigrationStep;
+import org.sonar.server.db.migrations.v45.AddMissingRuleParameterDefaultValuesMigrationStep;
+import org.sonar.server.db.migrations.v45.DeleteMeasuresOnDeletedProfilesMigrationStep;
+import org.sonar.server.db.migrations.v451.AddMissingCustomRuleParametersMigrationStep;
+import org.sonar.server.db.migrations.v451.DeleteUnescapedActivities;
+import org.sonar.server.db.migrations.v50.FeedFileSources;
+import org.sonar.server.db.migrations.v50.FeedIssueLongDates;
+import org.sonar.server.db.migrations.v50.FeedSnapshotSourcesUpdatedAt;
+import org.sonar.server.db.migrations.v50.InsertProjectsAuthorizationUpdatedAtMigrationStep;
+import org.sonar.server.db.migrations.v50.PopulateProjectsUuidColumnsMigrationStep;
+import org.sonar.server.db.migrations.v50.RemoveSortFieldFromIssueFiltersMigrationStep;
+import org.sonar.server.db.migrations.v50.ReplaceIssueFiltersProjectKeyByUuid;
+import org.sonar.server.db.migrations.v51.AddIssuesColumns;
+import org.sonar.server.db.migrations.v51.AddNewCharacteristics;
+import org.sonar.server.db.migrations.v51.CopyScmAccountsFromAuthorsToUsers;
+import org.sonar.server.db.migrations.v51.DropIssuesColumns;
+import org.sonar.server.db.migrations.v51.FeedAnalysisReportsLongDates;
+import org.sonar.server.db.migrations.v51.FeedEventsLongDates;
+import org.sonar.server.db.migrations.v51.FeedFileSourcesBinaryData;
+import org.sonar.server.db.migrations.v51.FeedIssueChangesLongDates;
+import org.sonar.server.db.migrations.v51.FeedIssueComponentUuids;
+import org.sonar.server.db.migrations.v51.FeedIssueTags;
+import org.sonar.server.db.migrations.v51.FeedIssuesLongDates;
+import org.sonar.server.db.migrations.v51.FeedManualMeasuresLongDates;
+import org.sonar.server.db.migrations.v51.FeedSemaphoresLongDates;
+import org.sonar.server.db.migrations.v51.FeedSnapshotsLongDates;
+import org.sonar.server.db.migrations.v51.FeedUsersLongDates;
+import org.sonar.server.db.migrations.v51.RemovePermissionsOnModulesMigrationStep;
+import org.sonar.server.db.migrations.v51.RenameComponentRelatedParamsInIssueFilters;
+import org.sonar.server.db.migrations.v51.UpdateProjectsModuleUuidPath;
+import org.sonar.server.db.migrations.v52.FeedEventsComponentUuid;
+import org.sonar.server.db.migrations.v52.FeedProjectLinksComponentUuid;
+import org.sonar.server.db.migrations.v52.MoveProjectProfileAssociation;
+
+import java.util.List;
+
+public interface MigrationSteps {
+
+  List<Class<? extends MigrationStep>> CLASSES = ImmutableList.of(
+    // 3.6
+    ViolationMigrationStep.class,
+
+    // 4.2
+    PackageKeysMigrationStep.class, CompleteIssueMessageMigrationStep.class,
+
+    // 4.3
+    ConvertIssueDebtToMinutesMigrationStep.class,
+    IssueChangelogMigrationStep.class,
+    TechnicalDebtMeasuresMigrationStep.class,
+    DevelopmentCostMeasuresMigrationStep.class,
+    RequirementMeasuresMigrationStep.class,
+    NotResolvedIssuesOnRemovedComponentsMigrationStep.class,
+
+    // 4.4
+    IssueActionPlanKeyMigrationStep.class,
+    MeasureDataMigrationStep.class,
+    FeedQProfileKeysMigrationStep.class,
+    FeedQProfileDatesMigrationStep.class,
+    ChangeLogMigrationStep.class,
+    ConvertProfileMeasuresMigrationStep.class,
+
+    // 4.5
+    AddMissingRuleParameterDefaultValuesMigrationStep.class,
+    DeleteMeasuresOnDeletedProfilesMigrationStep.class,
+
+    // 4.5.1
+    AddMissingCustomRuleParametersMigrationStep.class,
+    DeleteUnescapedActivities.class,
+
+    // 5.0
+    InsertProjectsAuthorizationUpdatedAtMigrationStep.class,
+    PopulateProjectsUuidColumnsMigrationStep.class,
+    ReplaceIssueFiltersProjectKeyByUuid.class,
+    FeedSnapshotSourcesUpdatedAt.class,
+    FeedFileSources.class,
+    FeedIssueLongDates.class,
+    RemoveSortFieldFromIssueFiltersMigrationStep.class,
+
+    // 5.1
+    FeedIssueTags.class,
+    FeedUsersLongDates.class,
+    RenameComponentRelatedParamsInIssueFilters.class,
+    CopyScmAccountsFromAuthorsToUsers.class,
+    FeedIssueChangesLongDates.class,
+    FeedAnalysisReportsLongDates.class,
+    UpdateProjectsModuleUuidPath.class,
+    FeedIssueComponentUuids.class,
+    FeedSnapshotsLongDates.class,
+    FeedIssuesLongDates.class,
+    FeedFileSourcesBinaryData.class,
+    FeedSemaphoresLongDates.class,
+    FeedManualMeasuresLongDates.class,
+    FeedEventsLongDates.class,
+    AddNewCharacteristics.class,
+    RemovePermissionsOnModulesMigrationStep.class,
+    AddIssuesColumns.class,
+    DropIssuesColumns.class,
+
+    // 5.2
+    FeedProjectLinksComponentUuid.class,
+    FeedEventsComponentUuid.class,
+    MoveProjectProfileAssociation.class
+    );
+}
index 869c74e33c9849be41a870bd9e7d659fc8ae6a84..8259660f63ee5cde10212ceedb0436ddac720923 100644 (file)
@@ -19,8 +19,6 @@
  */
 package org.sonar.server.db.migrations;
 
-import javax.annotation.CheckForNull;
-
 import java.sql.ResultSet;
 import java.sql.ResultSetMetaData;
 import java.sql.SQLException;
@@ -28,6 +26,8 @@ import java.sql.Timestamp;
 import java.util.Date;
 import java.util.List;
 
+import javax.annotation.CheckForNull;
+
 public interface Select extends SqlStatement<Select> {
 
   static class Row {
index 2c8e30821b8fb007b4cdb8c25f0ba2a7edbf31d8..a433b473e4a191ea82514c20ef089cd0a42b09bc 100644 (file)
@@ -19,9 +19,6 @@
  */
 package org.sonar.server.db.migrations;
 
-import org.apache.commons.dbutils.DbUtils;
-import org.sonar.core.persistence.Database;
-
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
@@ -29,6 +26,9 @@ import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.commons.dbutils.DbUtils;
+import org.sonar.core.persistence.Database;
+
 class SelectImpl extends BaseSqlStatement<Select> implements Select {
 
   private SelectImpl(PreparedStatement pstmt) {
index 1cf7d925ba4d06baf16af75e60286fe339066315..c6f8264567b99195c8e47e44c00fa9e89d63de89 100644 (file)
  */
 package org.sonar.server.db.migrations;
 
-import javax.annotation.Nullable;
-
 import java.sql.SQLException;
 import java.util.Date;
 
+import javax.annotation.Nullable;
+
 public interface SqlStatement<CHILD extends SqlStatement> {
   CHILD setBoolean(int columnIndex, @Nullable Boolean value) throws SQLException;
 
index 17b0f16b1de190a44bd534c570c24a4f1e3c5892..f528218723f07549fbf5beb38da0ad78ff077400 100644 (file)
  */
 package org.sonar.server.db.migrations;
 
-
-import org.sonar.api.utils.log.Logger;
-
-import javax.annotation.CheckForNull;
-
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Timestamp;
 import java.util.Date;
 
+import javax.annotation.CheckForNull;
+
+import org.sonar.api.utils.log.Logger;
+
 public class SqlUtil {
 
   private SqlUtil() {
index 3d5d88e30d0c808f78b6d88f0c6f830fcfc32f70..456e6d42a0d23d114c2464fddb3579058d5be1ee 100644 (file)
  */
 package org.sonar.server.db.migrations;
 
-import org.sonar.core.persistence.BatchSession;
-
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
 
+import org.sonar.core.persistence.BatchSession;
+
 public class UpsertImpl extends BaseSqlStatement<Upsert> implements Upsert {
 
   private long batchCount = 0L;
index 0e4c2e08273b4a82fc969de36b1b6fae72253c14..0e4f1a10d785893881c5f62d99149d6f37305186 100644 (file)
  */
 package org.sonar.server.db.migrations.v36;
 
+import java.util.TimerTask;
+import java.util.concurrent.atomic.AtomicLong;
 
 import org.sonar.api.utils.log.Logger;
 import org.sonar.api.utils.log.Loggers;
 
-import java.util.TimerTask;
-import java.util.concurrent.atomic.AtomicLong;
-
 /**
  * This task logs every minute the status of migration. It is destroyed
  * when migration is finished.
@@ -64,7 +63,7 @@ class Progress extends TimerTask {
       long remaining = (totalViolations - totalIssues) / frequency;
       logger.info(String.format(
         "%d%% [%d/%d violations, %d minutes remaining]", percents, totalIssues, totalViolations, remaining)
-      );
+        );
     } else {
       logger.info(String.format("%d%% [%d/%d violations]", percents, totalIssues, totalViolations));
     }
index f3bf398b1f7e27e468a7656924c46d1ee7e0ed40..f7ee441c6682ca43a55606b1d2c1ff564e41978e 100644 (file)
  */
 package org.sonar.server.db.migrations.v36;
 
-import com.google.common.collect.Maps;
-import org.apache.commons.dbutils.DbUtils;
-import org.apache.commons.dbutils.QueryRunner;
-import org.apache.commons.dbutils.ResultSetHandler;
-import org.sonar.core.persistence.Database;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
 import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.SQLException;
@@ -35,6 +27,16 @@ import java.util.Map;
 import java.util.Queue;
 import java.util.concurrent.ConcurrentLinkedQueue;
 
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
+
+import org.apache.commons.dbutils.DbUtils;
+import org.apache.commons.dbutils.QueryRunner;
+import org.apache.commons.dbutils.ResultSetHandler;
+import org.sonar.core.persistence.Database;
+
+import com.google.common.collect.Maps;
+
 /**
  * Data loaded from database before migrating violations. It is
  * shared amongst converter parallel tasks.
index c31aeb8b5f8000ca415104e96fea6c72a38bcb21..8e8bea4e63f7c5a63d6559470b14c8b1438a95af 100644 (file)
  */
 package org.sonar.server.db.migrations.v36;
 
-import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
+import java.sql.Connection;
+import java.sql.Date;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Callable;
+
 import org.apache.commons.dbutils.DbUtils;
 import org.apache.commons.dbutils.QueryRunner;
 import org.apache.commons.dbutils.handlers.AbstractListHandler;
@@ -31,13 +35,10 @@ import org.sonar.api.utils.internal.Uuids;
 import org.sonar.core.persistence.Database;
 import org.sonar.server.db.migrations.SqlUtil;
 
-import java.sql.Connection;
-import java.sql.Date;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.Callable;
+import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
 
 class ViolationConverter implements Callable<Object> {
 
index 6942c304f23920dca6eee3fcffbd898d2e19682d..8b127f323ebaa8034b0d3512333678d6f03e124b 100644 (file)
  */
 package org.sonar.server.db.migrations.v36;
 
-import com.google.common.collect.Lists;
-import org.sonar.api.config.Settings;
-import org.sonar.core.persistence.Database;
-
 import java.util.List;
 import java.util.Timer;
 import java.util.TimerTask;
@@ -31,6 +27,11 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
 
+import org.sonar.api.config.Settings;
+import org.sonar.core.persistence.Database;
+
+import com.google.common.collect.Lists;
+
 class ViolationConverters {
 
   static final int DEFAULT_THREADS = 5;
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v36/ViolationMigration.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v36/ViolationMigration.java
deleted file mode 100644 (file)
index c5e955b..0000000
+++ /dev/null
@@ -1,71 +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.
- */
-package org.sonar.server.db.migrations.v36;
-
-
-import org.sonar.api.config.Settings;
-import org.sonar.api.utils.MessageException;
-import org.sonar.api.utils.log.Logger;
-import org.sonar.api.utils.log.Loggers;
-import org.sonar.core.persistence.Database;
-import org.sonar.server.db.migrations.DatabaseMigration;
-import org.sonar.server.db.migrations.SqlUtil;
-
-import java.sql.SQLException;
-
-/**
- * Used in the Active Record Migration 401
- */
-public class ViolationMigration implements DatabaseMigration {
-
-  private static final Logger LOGGER = Loggers.get(ViolationMigration.class);
-
-  private static final String FAILURE_MESSAGE = "Fail to convert violations to issues";
-
-  private final Settings settings;
-  private final Database db;
-
-  public ViolationMigration(Database database, Settings settings) {
-    this.db = database;
-    this.settings = settings;
-  }
-
-  @Override
-  public void execute() {
-    try {
-      LOGGER.info("Initialize input");
-      Referentials referentials = new Referentials(db);
-      if (referentials.totalViolations() > 0) {
-        LOGGER.info("Migrate {} violations", referentials.totalViolations());
-        ViolationConverters converters = new ViolationConverters(settings);
-        converters.execute(referentials, db);
-      }
-    } catch (SQLException e) {
-      LOGGER.error(FAILURE_MESSAGE, e);
-      SqlUtil.log(LOGGER, e);
-      throw MessageException.of(FAILURE_MESSAGE);
-
-    } catch (Exception e) {
-      LOGGER.error(FAILURE_MESSAGE, e);
-      throw MessageException.of(FAILURE_MESSAGE);
-    }
-  }
-
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v36/ViolationMigrationStep.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v36/ViolationMigrationStep.java
new file mode 100644 (file)
index 0000000..2e51fa0
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
+package org.sonar.server.db.migrations.v36;
+
+import java.sql.SQLException;
+
+import org.sonar.api.config.Settings;
+import org.sonar.api.utils.MessageException;
+import org.sonar.api.utils.log.Logger;
+import org.sonar.api.utils.log.Loggers;
+import org.sonar.core.persistence.Database;
+import org.sonar.server.db.migrations.MigrationStep;
+import org.sonar.server.db.migrations.SqlUtil;
+
+/**
+ * Used in the Active Record Migration 401
+ */
+public class ViolationMigrationStep implements MigrationStep {
+
+  private static final Logger LOGGER = Loggers.get(ViolationMigrationStep.class);
+
+  private static final String FAILURE_MESSAGE = "Fail to convert violations to issues";
+
+  private final Settings settings;
+  private final Database db;
+
+  public ViolationMigrationStep(Database database, Settings settings) {
+    this.db = database;
+    this.settings = settings;
+  }
+
+  @Override
+  public void execute() {
+    try {
+      LOGGER.info("Initialize input");
+      Referentials referentials = new Referentials(db);
+      if (referentials.totalViolations() > 0) {
+        LOGGER.info("Migrate {} violations", referentials.totalViolations());
+        ViolationConverters converters = new ViolationConverters(settings);
+        converters.execute(referentials, db);
+      }
+    } catch (SQLException e) {
+      LOGGER.error(FAILURE_MESSAGE, e);
+      SqlUtil.log(LOGGER, e);
+      throw MessageException.of(FAILURE_MESSAGE);
+
+    } catch (Exception e) {
+      LOGGER.error(FAILURE_MESSAGE, e);
+      throw MessageException.of(FAILURE_MESSAGE);
+    }
+  }
+
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v42/CompleteIssueMessageMigration.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v42/CompleteIssueMessageMigration.java
deleted file mode 100644 (file)
index 14259d6..0000000
+++ /dev/null
@@ -1,58 +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.
- */
-package org.sonar.server.db.migrations.v42;
-
-import org.sonar.core.persistence.Database;
-import org.sonar.server.db.migrations.BaseDataChange;
-import org.sonar.server.db.migrations.MassUpdate;
-import org.sonar.server.db.migrations.Select;
-import org.sonar.server.db.migrations.SqlStatement;
-
-import java.sql.SQLException;
-
-/**
- * Used in Rails migration 497
- *
- * @since 4.2
- */
-public class CompleteIssueMessageMigration extends BaseDataChange {
-
-  public CompleteIssueMessageMigration(Database database) {
-    super(database);
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    MassUpdate massUpdate = context.prepareMassUpdate();
-    massUpdate.select("SELECT i.id, r.name FROM issues i INNER JOIN rules r ON r.id=i.rule_id WHERE i.message IS NULL");
-    massUpdate.update("UPDATE issues SET message=? WHERE id=?");
-    massUpdate.execute(new MassUpdate.Handler() {
-      @Override
-      public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
-        Long issueId = row.getNullableLong(1);
-        String ruleName = row.getNullableString(2);
-
-        update.setString(1, ruleName);
-        update.setLong(2, issueId);
-        return true;
-      }
-    });
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v42/CompleteIssueMessageMigrationStep.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v42/CompleteIssueMessageMigrationStep.java
new file mode 100644 (file)
index 0000000..71b4edc
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+package org.sonar.server.db.migrations.v42;
+
+import java.sql.SQLException;
+
+import org.sonar.core.persistence.Database;
+import org.sonar.server.db.migrations.BaseDataChange;
+import org.sonar.server.db.migrations.MassUpdate;
+import org.sonar.server.db.migrations.Select;
+import org.sonar.server.db.migrations.SqlStatement;
+
+/**
+ * Used in Rails migration 497
+ *
+ * @since 4.2
+ */
+public class CompleteIssueMessageMigrationStep extends BaseDataChange {
+
+  public CompleteIssueMessageMigrationStep(Database database) {
+    super(database);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    MassUpdate massUpdate = context.prepareMassUpdate();
+    massUpdate.select("SELECT i.id, r.name FROM issues i INNER JOIN rules r ON r.id=i.rule_id WHERE i.message IS NULL");
+    massUpdate.update("UPDATE issues SET message=? WHERE id=?");
+    massUpdate.execute(new MassUpdate.Handler() {
+      @Override
+      public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
+        Long issueId = row.getNullableLong(1);
+        String ruleName = row.getNullableString(2);
+
+        update.setString(1, ruleName);
+        update.setLong(2, issueId);
+        return true;
+      }
+    });
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v42/PackageKeysMigration.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v42/PackageKeysMigration.java
deleted file mode 100644 (file)
index 1a2e22b..0000000
+++ /dev/null
@@ -1,74 +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.
- */
-package org.sonar.server.db.migrations.v42;
-
-import org.apache.commons.lang.StringUtils;
-import org.sonar.core.persistence.Database;
-import org.sonar.server.db.migrations.BaseDataChange;
-import org.sonar.server.db.migrations.MassUpdate;
-import org.sonar.server.db.migrations.Select;
-import org.sonar.server.db.migrations.SqlStatement;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-import java.sql.SQLException;
-
-/**
- * Used in Rails migration 490
- *
- * @since 4.2
- */
-public class PackageKeysMigration extends BaseDataChange {
-
-  public PackageKeysMigration(Database database) {
-    super(database);
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    MassUpdate massUpdate = context.prepareMassUpdate();
-    massUpdate.select("SELECT id, kee FROM projects WHERE qualifier='PAC'");
-    massUpdate.update("UPDATE projects SET qualifier='DIR', kee=? WHERE id=?");
-    massUpdate.execute(new MassUpdate.Handler() {
-      @Override
-      public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
-        Long id = row.getNullableLong(1);
-        String key = row.getNullableString(2);
-        update.setString(1, convertKey(key));
-        update.setLong(2, id);
-        return true;
-      }
-    });
-  }
-
-  @CheckForNull
-  String convertKey(@Nullable String packageKey) {
-    if (packageKey != null) {
-      String prefix = StringUtils.substringBeforeLast(packageKey, ":") + ":";
-      String key = StringUtils.substringAfterLast(packageKey, ":");
-      if ("[default]".equals(key)) {
-        return prefix + "[root]";
-      }
-      return prefix + StringUtils.replace(key, ".", "/");
-    }
-    return null;
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v42/PackageKeysMigrationStep.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v42/PackageKeysMigrationStep.java
new file mode 100644 (file)
index 0000000..cf9c471
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * 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.
+ */
+package org.sonar.server.db.migrations.v42;
+
+import java.sql.SQLException;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
+
+import org.apache.commons.lang.StringUtils;
+import org.sonar.core.persistence.Database;
+import org.sonar.server.db.migrations.BaseDataChange;
+import org.sonar.server.db.migrations.MassUpdate;
+import org.sonar.server.db.migrations.Select;
+import org.sonar.server.db.migrations.SqlStatement;
+
+/**
+ * Used in Rails migration 490
+ *
+ * @since 4.2
+ */
+public class PackageKeysMigrationStep extends BaseDataChange {
+
+  public PackageKeysMigrationStep(Database database) {
+    super(database);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    MassUpdate massUpdate = context.prepareMassUpdate();
+    massUpdate.select("SELECT id, kee FROM projects WHERE qualifier='PAC'");
+    massUpdate.update("UPDATE projects SET qualifier='DIR', kee=? WHERE id=?");
+    massUpdate.execute(new MassUpdate.Handler() {
+      @Override
+      public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
+        Long id = row.getNullableLong(1);
+        String key = row.getNullableString(2);
+        update.setString(1, convertKey(key));
+        update.setLong(2, id);
+        return true;
+      }
+    });
+  }
+
+  @CheckForNull
+  String convertKey(@Nullable String packageKey) {
+    if (packageKey != null) {
+      String prefix = StringUtils.substringBeforeLast(packageKey, ":") + ":";
+      String key = StringUtils.substringAfterLast(packageKey, ":");
+      if ("[default]".equals(key)) {
+        return prefix + "[root]";
+      }
+      return prefix + StringUtils.replace(key, ".", "/");
+    }
+    return null;
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/ConvertIssueDebtToMinutesMigration.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/ConvertIssueDebtToMinutesMigration.java
deleted file mode 100644 (file)
index 091eb2a..0000000
+++ /dev/null
@@ -1,79 +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.
- */
-
-package org.sonar.server.db.migrations.v43;
-
-import org.sonar.api.utils.System2;
-import org.sonar.core.persistence.Database;
-import org.sonar.core.properties.PropertiesDao;
-import org.sonar.server.db.migrations.BaseDataChange;
-import org.sonar.server.db.migrations.MassUpdate;
-import org.sonar.server.db.migrations.Select;
-import org.sonar.server.db.migrations.SqlStatement;
-
-import java.sql.SQLException;
-import java.util.Date;
-
-/**
- * Used in the Active Record Migration 513.
- * WARNING - this migration is not re-entrant.
- *
- * @since 4.3
- */
-public class ConvertIssueDebtToMinutesMigration extends BaseDataChange {
-
-  private final WorkDurationConvertor workDurationConvertor;
-  private final System2 system2;
-
-  public ConvertIssueDebtToMinutesMigration(Database database, PropertiesDao propertiesDao, System2 system2) {
-    super(database);
-    this.workDurationConvertor = new WorkDurationConvertor(propertiesDao);
-    this.system2 = system2;
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    workDurationConvertor.init();
-    final Date now = new Date(system2.now());
-    MassUpdate massUpdate = context.prepareMassUpdate();
-
-    // See https://jira.codehaus.org/browse/SONAR-5394
-    // The SQL request should not set the filter on technical_debt is not null. There's no index
-    // on this column, so filtering is done programmatically.
-    massUpdate.select("select id, technical_debt from issues");
-
-    massUpdate.update("update issues set technical_debt=?, updated_at=? where id=?");
-    massUpdate.execute(new MassUpdate.Handler() {
-      @Override
-      public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
-        Long debt = row.getNullableLong(2);
-        if (debt != null) {
-          Long id = row.getNullableLong(1);
-          update.setLong(1, workDurationConvertor.createFromLong(debt));
-          update.setDate(2, now);
-          update.setLong(3, id);
-          return true;
-        }
-        return false;
-      }
-    });
-  }
-
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/ConvertIssueDebtToMinutesMigrationStep.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/ConvertIssueDebtToMinutesMigrationStep.java
new file mode 100644 (file)
index 0000000..9f29e1e
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * 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.
+ */
+
+package org.sonar.server.db.migrations.v43;
+
+import java.sql.SQLException;
+import java.util.Date;
+
+import org.sonar.api.utils.System2;
+import org.sonar.core.persistence.Database;
+import org.sonar.core.properties.PropertiesDao;
+import org.sonar.server.db.migrations.BaseDataChange;
+import org.sonar.server.db.migrations.MassUpdate;
+import org.sonar.server.db.migrations.Select;
+import org.sonar.server.db.migrations.SqlStatement;
+
+/**
+ * Used in the Active Record Migration 513.
+ * WARNING - this migration is not re-entrant.
+ *
+ * @since 4.3
+ */
+public class ConvertIssueDebtToMinutesMigrationStep extends BaseDataChange {
+
+  private final WorkDurationConvertor workDurationConvertor;
+  private final System2 system2;
+
+  public ConvertIssueDebtToMinutesMigrationStep(Database database, PropertiesDao propertiesDao, System2 system2) {
+    super(database);
+    this.workDurationConvertor = new WorkDurationConvertor(propertiesDao);
+    this.system2 = system2;
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    workDurationConvertor.init();
+    final Date now = new Date(system2.now());
+    MassUpdate massUpdate = context.prepareMassUpdate();
+
+    // See https://jira.codehaus.org/browse/SONAR-5394
+    // The SQL request should not set the filter on technical_debt is not null. There's no index
+    // on this column, so filtering is done programmatically.
+    massUpdate.select("select id, technical_debt from issues");
+
+    massUpdate.update("update issues set technical_debt=?, updated_at=? where id=?");
+    massUpdate.execute(new MassUpdate.Handler() {
+      @Override
+      public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
+        Long debt = row.getNullableLong(2);
+        if (debt != null) {
+          Long id = row.getNullableLong(1);
+          update.setLong(1, workDurationConvertor.createFromLong(debt));
+          update.setDate(2, now);
+          update.setLong(3, id);
+          return true;
+        }
+        return false;
+      }
+    });
+  }
+
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/DevelopmentCostMeasuresMigration.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/DevelopmentCostMeasuresMigration.java
deleted file mode 100644 (file)
index 6345bc5..0000000
+++ /dev/null
@@ -1,75 +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.
- */
-
-package org.sonar.server.db.migrations.v43;
-
-import org.sonar.core.persistence.Database;
-import org.sonar.core.properties.PropertiesDao;
-import org.sonar.server.db.migrations.BaseDataChange;
-import org.sonar.server.db.migrations.MassUpdate;
-import org.sonar.server.db.migrations.Select;
-import org.sonar.server.db.migrations.SqlStatement;
-
-import javax.annotation.CheckForNull;
-
-import java.sql.SQLException;
-
-/**
- * Used in the Active Record Migration 516
- *
- * @since 4.3
- */
-public class DevelopmentCostMeasuresMigration extends BaseDataChange {
-
-  private final WorkDurationConvertor workDurationConvertor;
-
-  public DevelopmentCostMeasuresMigration(Database database, PropertiesDao propertiesDao) {
-    super(database);
-    this.workDurationConvertor = new WorkDurationConvertor(propertiesDao);
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    workDurationConvertor.init();
-
-    Long metricId = context.prepareSelect("select id from metrics where name='development_cost'").get(Select.LONG_READER);
-    if (metricId != null) {
-      MassUpdate massUpdate = context.prepareMassUpdate();
-      massUpdate.select("select id, value from project_measures where metric_id=? and value is not null").setLong(1, metricId);
-      massUpdate.update("update project_measures set value=NULL,text_value=? where id=?");
-      massUpdate.execute(new MassUpdate.Handler() {
-        @Override
-        public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
-          Long id = row.getNullableLong(1);
-          Double value = row.getNullableDouble(2);
-
-          update.setString(1, convertDebtForDays(value));
-          update.setLong(2, id);
-          return true;
-        }
-      });
-    }
-  }
-
-  @CheckForNull
-  private String convertDebtForDays(Double data) {
-    return Long.toString(workDurationConvertor.createFromDays(data));
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/DevelopmentCostMeasuresMigrationStep.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/DevelopmentCostMeasuresMigrationStep.java
new file mode 100644 (file)
index 0000000..3f0ef33
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * 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.
+ */
+
+package org.sonar.server.db.migrations.v43;
+
+import java.sql.SQLException;
+
+import javax.annotation.CheckForNull;
+
+import org.sonar.core.persistence.Database;
+import org.sonar.core.properties.PropertiesDao;
+import org.sonar.server.db.migrations.BaseDataChange;
+import org.sonar.server.db.migrations.MassUpdate;
+import org.sonar.server.db.migrations.Select;
+import org.sonar.server.db.migrations.SqlStatement;
+
+/**
+ * Used in the Active Record Migration 516
+ *
+ * @since 4.3
+ */
+public class DevelopmentCostMeasuresMigrationStep extends BaseDataChange {
+
+  private final WorkDurationConvertor workDurationConvertor;
+
+  public DevelopmentCostMeasuresMigrationStep(Database database, PropertiesDao propertiesDao) {
+    super(database);
+    this.workDurationConvertor = new WorkDurationConvertor(propertiesDao);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    workDurationConvertor.init();
+
+    Long metricId = context.prepareSelect("select id from metrics where name='development_cost'").get(Select.LONG_READER);
+    if (metricId != null) {
+      MassUpdate massUpdate = context.prepareMassUpdate();
+      massUpdate.select("select id, value from project_measures where metric_id=? and value is not null").setLong(1, metricId);
+      massUpdate.update("update project_measures set value=NULL,text_value=? where id=?");
+      massUpdate.execute(new MassUpdate.Handler() {
+        @Override
+        public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
+          Long id = row.getNullableLong(1);
+          Double value = row.getNullableDouble(2);
+
+          update.setString(1, convertDebtForDays(value));
+          update.setLong(2, id);
+          return true;
+        }
+      });
+    }
+  }
+
+  @CheckForNull
+  private String convertDebtForDays(Double data) {
+    return Long.toString(workDurationConvertor.createFromDays(data));
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/IssueChangelogMigration.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/IssueChangelogMigration.java
deleted file mode 100644 (file)
index de3c557..0000000
+++ /dev/null
@@ -1,112 +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.
- */
-
-package org.sonar.server.db.migrations.v43;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Strings;
-import org.sonar.api.utils.System2;
-import org.sonar.core.persistence.Database;
-import org.sonar.core.properties.PropertiesDao;
-import org.sonar.server.db.migrations.BaseDataChange;
-import org.sonar.server.db.migrations.MassUpdate;
-import org.sonar.server.db.migrations.Select;
-import org.sonar.server.db.migrations.SqlStatement;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-import java.sql.SQLException;
-import java.util.Date;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Used in the Active Record Migration 514
- *
- * @since 4.3
- */
-public class IssueChangelogMigration extends BaseDataChange {
-
-  private final WorkDurationConvertor workDurationConvertor;
-  private final System2 system2;
-  private final Pattern pattern = Pattern.compile("technicalDebt=(\\d*)\\|(\\d*)", Pattern.CASE_INSENSITIVE);
-
-  public IssueChangelogMigration(Database database, System2 system2, PropertiesDao propertiesDao) {
-    this(database, system2, new WorkDurationConvertor(propertiesDao));
-  }
-
-  @VisibleForTesting
-  IssueChangelogMigration(Database database, System2 system2, WorkDurationConvertor convertor) {
-    super(database);
-    this.workDurationConvertor = convertor;
-    this.system2 = system2;
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    workDurationConvertor.init();
-    final Date now = new Date(system2.now());
-    MassUpdate massUpdate = context.prepareMassUpdate();
-    massUpdate.select("SELECT ic.id, ic.change_data  FROM issue_changes ic " +
-      "WHERE ic.change_type = 'diff' AND ic.change_data LIKE '%technicalDebt%'");
-    massUpdate.update("UPDATE issue_changes SET change_data=?,updated_at=? WHERE id=?");
-    massUpdate.execute(new MassUpdate.Handler() {
-      @Override
-      public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
-        Long id = row.getNullableLong(1);
-        String changeData = row.getNullableString(2);
-
-        update.setString(1, convertChangelog(changeData));
-        update.setDate(2, now);
-        update.setLong(3, id);
-        return true;
-      }
-    });
-  }
-
-  @VisibleForTesting
-  @CheckForNull
-  String convertChangelog(@Nullable String data) {
-    if (data == null) {
-      return null;
-    }
-    Matcher matcher = pattern.matcher(data);
-    StringBuffer sb = new StringBuffer();
-    if (matcher.find()) {
-      String replacement = "technicalDebt=";
-      String oldValue = matcher.group(1);
-      if (!Strings.isNullOrEmpty(oldValue)) {
-        long oldDebt = workDurationConvertor.createFromLong(Long.parseLong(oldValue));
-        replacement += Long.toString(oldDebt);
-      }
-      replacement += "|";
-      String newValue = matcher.group(2);
-      if (!Strings.isNullOrEmpty(newValue)) {
-        long newDebt = workDurationConvertor.createFromLong(Long.parseLong(newValue));
-        replacement += Long.toString(newDebt);
-      }
-      matcher.appendReplacement(sb, replacement);
-    }
-    matcher.appendTail(sb);
-    return sb.toString();
-  }
-
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/IssueChangelogMigrationStep.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/IssueChangelogMigrationStep.java
new file mode 100644 (file)
index 0000000..edeab04
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * 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.
+ */
+
+package org.sonar.server.db.migrations.v43;
+
+import java.sql.SQLException;
+import java.util.Date;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
+
+import org.sonar.api.utils.System2;
+import org.sonar.core.persistence.Database;
+import org.sonar.core.properties.PropertiesDao;
+import org.sonar.server.db.migrations.BaseDataChange;
+import org.sonar.server.db.migrations.MassUpdate;
+import org.sonar.server.db.migrations.Select;
+import org.sonar.server.db.migrations.SqlStatement;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Strings;
+
+/**
+ * Used in the Active Record Migration 514
+ *
+ * @since 4.3
+ */
+public class IssueChangelogMigrationStep extends BaseDataChange {
+
+  private final WorkDurationConvertor workDurationConvertor;
+  private final System2 system2;
+  private final Pattern pattern = Pattern.compile("technicalDebt=(\\d*)\\|(\\d*)", Pattern.CASE_INSENSITIVE);
+
+  public IssueChangelogMigrationStep(Database database, System2 system2, PropertiesDao propertiesDao) {
+    this(database, system2, new WorkDurationConvertor(propertiesDao));
+  }
+
+  @VisibleForTesting
+  IssueChangelogMigrationStep(Database database, System2 system2, WorkDurationConvertor convertor) {
+    super(database);
+    this.workDurationConvertor = convertor;
+    this.system2 = system2;
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    workDurationConvertor.init();
+    final Date now = new Date(system2.now());
+    MassUpdate massUpdate = context.prepareMassUpdate();
+    massUpdate.select("SELECT ic.id, ic.change_data  FROM issue_changes ic " +
+      "WHERE ic.change_type = 'diff' AND ic.change_data LIKE '%technicalDebt%'");
+    massUpdate.update("UPDATE issue_changes SET change_data=?,updated_at=? WHERE id=?");
+    massUpdate.execute(new MassUpdate.Handler() {
+      @Override
+      public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
+        Long id = row.getNullableLong(1);
+        String changeData = row.getNullableString(2);
+
+        update.setString(1, convertChangelog(changeData));
+        update.setDate(2, now);
+        update.setLong(3, id);
+        return true;
+      }
+    });
+  }
+
+  @VisibleForTesting
+  @CheckForNull
+  String convertChangelog(@Nullable String data) {
+    if (data == null) {
+      return null;
+    }
+    Matcher matcher = pattern.matcher(data);
+    StringBuffer sb = new StringBuffer();
+    if (matcher.find()) {
+      String replacement = "technicalDebt=";
+      String oldValue = matcher.group(1);
+      if (!Strings.isNullOrEmpty(oldValue)) {
+        long oldDebt = workDurationConvertor.createFromLong(Long.parseLong(oldValue));
+        replacement += Long.toString(oldDebt);
+      }
+      replacement += "|";
+      String newValue = matcher.group(2);
+      if (!Strings.isNullOrEmpty(newValue)) {
+        long newDebt = workDurationConvertor.createFromLong(Long.parseLong(newValue));
+        replacement += Long.toString(newDebt);
+      }
+      matcher.appendReplacement(sb, replacement);
+    }
+    matcher.appendTail(sb);
+    return sb.toString();
+  }
+
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/NotResolvedIssuesOnRemovedComponentsMigration.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/NotResolvedIssuesOnRemovedComponentsMigration.java
deleted file mode 100644 (file)
index 6c740c6..0000000
+++ /dev/null
@@ -1,68 +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.
- */
-
-package org.sonar.server.db.migrations.v43;
-
-import org.sonar.api.issue.Issue;
-import org.sonar.api.utils.System2;
-import org.sonar.core.persistence.Database;
-import org.sonar.server.db.migrations.BaseDataChange;
-import org.sonar.server.db.migrations.MassUpdate;
-import org.sonar.server.db.migrations.Select;
-import org.sonar.server.db.migrations.SqlStatement;
-
-import java.sql.SQLException;
-import java.util.Date;
-
-/**
- * Used in the Active Record Migration 525
- *
- * @since 4.3
- */
-public class NotResolvedIssuesOnRemovedComponentsMigration extends BaseDataChange {
-
-  private final System2 system2;
-
-  public NotResolvedIssuesOnRemovedComponentsMigration(Database database, System2 system2) {
-    super(database);
-    this.system2 = system2;
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    final Date now = new Date(system2.now());
-    MassUpdate massUpdate = context.prepareMassUpdate();
-    massUpdate.select("SELECT i.id FROM issues i " +
-      "INNER JOIN projects p on p.id=i.component_id " +
-      "WHERE p.enabled=? AND i.resolution IS NULL ").setBoolean(1, false);
-    massUpdate.update("UPDATE issues SET status=?,resolution=?,updated_at=? WHERE id=?");
-    massUpdate.execute(new MassUpdate.Handler() {
-      @Override
-      public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
-        Long id = row.getNullableLong(1);
-        update.setString(1, Issue.STATUS_CLOSED);
-        update.setString(2, Issue.RESOLUTION_REMOVED);
-        update.setDate(3, now);
-        update.setLong(4, id);
-        return true;
-      }
-    });
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/NotResolvedIssuesOnRemovedComponentsMigrationStep.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/NotResolvedIssuesOnRemovedComponentsMigrationStep.java
new file mode 100644 (file)
index 0000000..d8e0271
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * 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.
+ */
+
+package org.sonar.server.db.migrations.v43;
+
+import java.sql.SQLException;
+import java.util.Date;
+
+import org.sonar.api.issue.Issue;
+import org.sonar.api.utils.System2;
+import org.sonar.core.persistence.Database;
+import org.sonar.server.db.migrations.BaseDataChange;
+import org.sonar.server.db.migrations.MassUpdate;
+import org.sonar.server.db.migrations.Select;
+import org.sonar.server.db.migrations.SqlStatement;
+
+/**
+ * Used in the Active Record Migration 525
+ *
+ * @since 4.3
+ */
+public class NotResolvedIssuesOnRemovedComponentsMigrationStep extends BaseDataChange {
+
+  private final System2 system2;
+
+  public NotResolvedIssuesOnRemovedComponentsMigrationStep(Database database, System2 system2) {
+    super(database);
+    this.system2 = system2;
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    final Date now = new Date(system2.now());
+    MassUpdate massUpdate = context.prepareMassUpdate();
+    massUpdate.select("SELECT i.id FROM issues i " +
+      "INNER JOIN projects p on p.id=i.component_id " +
+      "WHERE p.enabled=? AND i.resolution IS NULL ").setBoolean(1, false);
+    massUpdate.update("UPDATE issues SET status=?,resolution=?,updated_at=? WHERE id=?");
+    massUpdate.execute(new MassUpdate.Handler() {
+      @Override
+      public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
+        Long id = row.getNullableLong(1);
+        update.setString(1, Issue.STATUS_CLOSED);
+        update.setString(2, Issue.RESOLUTION_REMOVED);
+        update.setDate(3, now);
+        update.setLong(4, id);
+        return true;
+      }
+    });
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/RequirementMeasuresMigration.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/RequirementMeasuresMigration.java
deleted file mode 100644 (file)
index ba68b29..0000000
+++ /dev/null
@@ -1,61 +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.
- */
-
-package org.sonar.server.db.migrations.v43;
-
-import org.sonar.core.persistence.Database;
-import org.sonar.server.db.migrations.BaseDataChange;
-import org.sonar.server.db.migrations.MassUpdate;
-import org.sonar.server.db.migrations.Select;
-import org.sonar.server.db.migrations.SqlStatement;
-
-import java.sql.SQLException;
-
-/**
- * Used in the Active Record Migration 521
- *
- * @since 4.3
- */
-public class RequirementMeasuresMigration extends BaseDataChange {
-
-  public RequirementMeasuresMigration(Database database) {
-    super(database);
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    MassUpdate massUpdate = context.prepareMassUpdate();
-    massUpdate.select("SELECT project_measures.id,characteristics.rule_id FROM project_measures " +
-      "INNER JOIN characteristics ON characteristics.id = project_measures.characteristic_id " +
-      "WHERE characteristics.rule_id IS NOT NULL");
-    massUpdate.update("UPDATE project_measures SET characteristic_id=null,rule_id=? WHERE id=?");
-    massUpdate.execute(new MassUpdate.Handler() {
-      @Override
-      public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
-        Long id = row.getNullableLong(1);
-        Long ruleId = row.getNullableLong(2);
-
-        update.setLong(1, ruleId);
-        update.setLong(2, id);
-        return true;
-      }
-    });
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/RequirementMeasuresMigrationStep.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/RequirementMeasuresMigrationStep.java
new file mode 100644 (file)
index 0000000..5474d97
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+
+package org.sonar.server.db.migrations.v43;
+
+import java.sql.SQLException;
+
+import org.sonar.core.persistence.Database;
+import org.sonar.server.db.migrations.BaseDataChange;
+import org.sonar.server.db.migrations.MassUpdate;
+import org.sonar.server.db.migrations.Select;
+import org.sonar.server.db.migrations.SqlStatement;
+
+/**
+ * Used in the Active Record Migration 521
+ *
+ * @since 4.3
+ */
+public class RequirementMeasuresMigrationStep extends BaseDataChange {
+
+  public RequirementMeasuresMigrationStep(Database database) {
+    super(database);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    MassUpdate massUpdate = context.prepareMassUpdate();
+    massUpdate.select("SELECT project_measures.id,characteristics.rule_id FROM project_measures " +
+      "INNER JOIN characteristics ON characteristics.id = project_measures.characteristic_id " +
+      "WHERE characteristics.rule_id IS NOT NULL");
+    massUpdate.update("UPDATE project_measures SET characteristic_id=null,rule_id=? WHERE id=?");
+    massUpdate.execute(new MassUpdate.Handler() {
+      @Override
+      public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
+        Long id = row.getNullableLong(1);
+        Long ruleId = row.getNullableLong(2);
+
+        update.setLong(1, ruleId);
+        update.setLong(2, id);
+        return true;
+      }
+    });
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/TechnicalDebtMeasuresMigration.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/TechnicalDebtMeasuresMigration.java
deleted file mode 100644 (file)
index 2ce4084..0000000
+++ /dev/null
@@ -1,108 +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.
- */
-
-package org.sonar.server.db.migrations.v43;
-
-import org.apache.commons.lang.StringUtils;
-import org.sonar.core.persistence.Database;
-import org.sonar.core.properties.PropertiesDao;
-import org.sonar.server.db.migrations.BaseDataChange;
-import org.sonar.server.db.migrations.MassUpdate;
-import org.sonar.server.db.migrations.Select;
-import org.sonar.server.db.migrations.SqlStatement;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-import java.sql.SQLException;
-import java.util.List;
-
-/**
- * Used in the Active Record Migration 515
- *
- * @since 4.3
- */
-public class TechnicalDebtMeasuresMigration extends BaseDataChange {
-
-  private final WorkDurationConvertor workDurationConvertor;
-
-  public TechnicalDebtMeasuresMigration(Database database, PropertiesDao propertiesDao) {
-    super(database);
-    this.workDurationConvertor = new WorkDurationConvertor(propertiesDao);
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    workDurationConvertor.init();
-
-    List<Long> metricIds = context.prepareSelect("select id from metrics " +
-      "where name='sqale_index' or name='new_technical_debt' " +
-      "or name='sqale_effort_to_grade_a' or name='sqale_effort_to_grade_b' or name='sqale_effort_to_grade_c' " +
-      "or name='sqale_effort_to_grade_d' or name='blocker_remediation_cost' or name='critical_remediation_cost' " +
-      "or name='major_remediation_cost' or name='minor_remediation_cost' or name='info_remediation_cost'").list(Select.LONG_READER);
-
-    if (!metricIds.isEmpty()) {
-      MassUpdate massUpdate = context.prepareMassUpdate();
-      massUpdate.rowPluralName("measures");
-
-      SqlStatement select = massUpdate.select("SELECT pm.id, pm.value " +
-        ", pm.variation_value_1 , pm.variation_value_2, pm.variation_value_3 " +
-        ", pm.variation_value_4 , pm.variation_value_5 " +
-        " FROM project_measures pm " +
-        " WHERE pm.metric_id IN (" + StringUtils.repeat("?", ",", metricIds.size()) + ")");
-      for (int i = 0; i < metricIds.size(); i++) {
-        select.setLong(i + 1, metricIds.get(i));
-      }
-      massUpdate.update("UPDATE project_measures SET value=?," +
-        "variation_value_1=?,variation_value_2=?,variation_value_3=?,variation_value_4=?,variation_value_5=? WHERE id=?");
-      massUpdate.execute(new Converter());
-    }
-  }
-
-  private class Converter implements MassUpdate.Handler {
-    @Override
-    public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
-      Long id = row.getNullableLong(1);
-      Double value = row.getNullableDouble(2);
-      Double var1 = row.getNullableDouble(3);
-      Double var2 = row.getNullableDouble(4);
-      Double var3 = row.getNullableDouble(5);
-      Double var4 = row.getNullableDouble(6);
-      Double var5 = row.getNullableDouble(7);
-
-      update.setLong(1, convertDebtForDays(value));
-      update.setLong(2, convertDebtForDays(var1));
-      update.setLong(3, convertDebtForDays(var2));
-      update.setLong(4, convertDebtForDays(var3));
-      update.setLong(5, convertDebtForDays(var4));
-      update.setLong(6, convertDebtForDays(var5));
-      update.setLong(7, id);
-      return true;
-    }
-
-    @CheckForNull
-    private Long convertDebtForDays(@Nullable Double data) {
-      if (data != null) {
-        return workDurationConvertor.createFromDays(data);
-      }
-      return null;
-    }
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/TechnicalDebtMeasuresMigrationStep.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v43/TechnicalDebtMeasuresMigrationStep.java
new file mode 100644 (file)
index 0000000..b892e46
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * 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.
+ */
+
+package org.sonar.server.db.migrations.v43;
+
+import java.sql.SQLException;
+import java.util.List;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
+
+import org.apache.commons.lang.StringUtils;
+import org.sonar.core.persistence.Database;
+import org.sonar.core.properties.PropertiesDao;
+import org.sonar.server.db.migrations.BaseDataChange;
+import org.sonar.server.db.migrations.MassUpdate;
+import org.sonar.server.db.migrations.Select;
+import org.sonar.server.db.migrations.SqlStatement;
+
+/**
+ * Used in the Active Record Migration 515
+ *
+ * @since 4.3
+ */
+public class TechnicalDebtMeasuresMigrationStep extends BaseDataChange {
+
+  private final WorkDurationConvertor workDurationConvertor;
+
+  public TechnicalDebtMeasuresMigrationStep(Database database, PropertiesDao propertiesDao) {
+    super(database);
+    this.workDurationConvertor = new WorkDurationConvertor(propertiesDao);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    workDurationConvertor.init();
+
+    List<Long> metricIds = context.prepareSelect("select id from metrics " +
+      "where name='sqale_index' or name='new_technical_debt' " +
+      "or name='sqale_effort_to_grade_a' or name='sqale_effort_to_grade_b' or name='sqale_effort_to_grade_c' " +
+      "or name='sqale_effort_to_grade_d' or name='blocker_remediation_cost' or name='critical_remediation_cost' " +
+      "or name='major_remediation_cost' or name='minor_remediation_cost' or name='info_remediation_cost'").list(Select.LONG_READER);
+
+    if (!metricIds.isEmpty()) {
+      MassUpdate massUpdate = context.prepareMassUpdate();
+      massUpdate.rowPluralName("measures");
+
+      SqlStatement select = massUpdate.select("SELECT pm.id, pm.value " +
+        ", pm.variation_value_1 , pm.variation_value_2, pm.variation_value_3 " +
+        ", pm.variation_value_4 , pm.variation_value_5 " +
+        " FROM project_measures pm " +
+        " WHERE pm.metric_id IN (" + StringUtils.repeat("?", ",", metricIds.size()) + ")");
+      for (int i = 0; i < metricIds.size(); i++) {
+        select.setLong(i + 1, metricIds.get(i));
+      }
+      massUpdate.update("UPDATE project_measures SET value=?," +
+        "variation_value_1=?,variation_value_2=?,variation_value_3=?,variation_value_4=?,variation_value_5=? WHERE id=?");
+      massUpdate.execute(new Converter());
+    }
+  }
+
+  private class Converter implements MassUpdate.Handler {
+    @Override
+    public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
+      Long id = row.getNullableLong(1);
+      Double value = row.getNullableDouble(2);
+      Double var1 = row.getNullableDouble(3);
+      Double var2 = row.getNullableDouble(4);
+      Double var3 = row.getNullableDouble(5);
+      Double var4 = row.getNullableDouble(6);
+      Double var5 = row.getNullableDouble(7);
+
+      update.setLong(1, convertDebtForDays(value));
+      update.setLong(2, convertDebtForDays(var1));
+      update.setLong(3, convertDebtForDays(var2));
+      update.setLong(4, convertDebtForDays(var3));
+      update.setLong(5, convertDebtForDays(var4));
+      update.setLong(6, convertDebtForDays(var5));
+      update.setLong(7, id);
+      return true;
+    }
+
+    @CheckForNull
+    private Long convertDebtForDays(@Nullable Double data) {
+      if (data != null) {
+        return workDurationConvertor.createFromDays(data);
+      }
+      return null;
+    }
+  }
+}
index bcdab54e5cb569303f749d298f48d340e2316c65..fd127cf2170c3be8eabbb980c0d886b85da09439 100644 (file)
@@ -78,7 +78,7 @@ class WorkDurationConvertor {
     }
   }
 
-  private void checkHoursInDay(){
+  private void checkHoursInDay() {
     if (hoursInDay == null) {
       throw new IllegalStateException("init() has not been called");
     }
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/ChangeLogMigration.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/ChangeLogMigration.java
deleted file mode 100644 (file)
index ca1ca12..0000000
+++ /dev/null
@@ -1,129 +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.
- */
-package org.sonar.server.db.migrations.v44;
-
-import org.apache.commons.lang.StringUtils;
-import org.sonar.api.rule.RuleKey;
-import org.sonar.api.utils.KeyValueFormat;
-import org.sonar.api.utils.internal.Uuids;
-import org.sonar.core.activity.db.ActivityDto;
-import org.sonar.core.persistence.DbSession;
-import org.sonar.core.persistence.migration.v44.ChangeLog;
-import org.sonar.core.persistence.migration.v44.Migration44Mapper;
-import org.sonar.core.qualityprofile.db.ActiveRuleKey;
-import org.sonar.core.rule.SeverityUtil;
-import org.sonar.server.activity.Activity;
-import org.sonar.server.activity.db.ActivityDao;
-import org.sonar.server.db.DbClient;
-import org.sonar.server.db.migrations.DatabaseMigration;
-import org.sonar.server.qualityprofile.ActiveRuleChange;
-
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * SONAR-5329
- * Transition ActiveRuleChanges to ActivityLog
- * <p/>
- * Used in the Active Record Migration 548.
- *
- * @since 4.4
- */
-public class ChangeLogMigration implements DatabaseMigration {
-
-  private final ActivityDao dao;
-  private final DbClient db;
-
-  public ChangeLogMigration(ActivityDao dao, DbClient db) {
-    this.dao = dao;
-    this.db = db;
-  }
-
-  @Override
-  public void execute() {
-    DbSession session = db.openSession(false);
-    Migration44Mapper migrationMapper = session.getMapper(Migration44Mapper.class);
-    try {
-      executeUpsert(session, ActiveRuleChange.Type.ACTIVATED, migrationMapper.selectActiveRuleChange(true));
-      executeUpsert(session, ActiveRuleChange.Type.UPDATED, migrationMapper.selectActiveRuleChange(null));
-      executeUpsert(session, ActiveRuleChange.Type.DEACTIVATED, migrationMapper.selectActiveRuleChange(false));
-      session.commit();
-    } finally {
-      session.close();
-    }
-  }
-
-  private void executeUpsert(DbSession session, ActiveRuleChange.Type type, List<ChangeLog> changes) {
-
-    Iterator<ChangeLog> changeLogIterator = changes.iterator();
-    if (changeLogIterator.hasNext()) {
-      // startCase
-      ChangeLog change = changeLogIterator.next();
-      int currentId = change.getId();
-      Date currentTimeStamp = change.getCreatedAt();
-      String currentAuthor = change.getUserLogin();
-      ActiveRuleChange ruleChange = newActiveRuleChance(type, change);
-      processRuleChange(ruleChange, change);
-
-      while (changeLogIterator.hasNext()) {
-        change = changeLogIterator.next();
-        int id = change.getId();
-        if (id != currentId) {
-          saveActiveRuleChange(session, ruleChange, currentAuthor, currentTimeStamp);
-          currentId = id;
-          currentTimeStamp = change.getCreatedAt();
-          currentAuthor = change.getUserLogin();
-          ruleChange = newActiveRuleChance(type, change);
-        }
-        processRuleChange(ruleChange, change);
-      }
-      // save the last
-      saveActiveRuleChange(session, ruleChange, currentAuthor, currentTimeStamp);
-    }
-  }
-
-  private void saveActiveRuleChange(DbSession session, ActiveRuleChange ruleChange, String author, Date currentTimeStamp) {
-    Activity activity = ruleChange.toActivity();
-    ActivityDto dto = new ActivityDto();
-    dto.setKey(Uuids.create());
-    dto.setType(Activity.Type.QPROFILE.name());
-    dto.setAction(activity.getAction());
-    dto.setMessage(activity.getMessage());
-    dto.setAuthor(author);
-    dto.setData(KeyValueFormat.format(activity.getData()));
-    dto.setCreatedAt(currentTimeStamp);
-    dao.insert(session, dto);
-  }
-
-  private void processRuleChange(ActiveRuleChange ruleChange, ChangeLog change) {
-    ruleChange.setSeverity(SeverityUtil.getSeverityFromOrdinal(change.getSeverity()));
-    String paramName = change.getParamKey();
-    String paramValue = change.getParamValue();
-    if (StringUtils.isNotEmpty(paramName)) {
-      ruleChange.setParameter(paramName, paramValue);
-    }
-  }
-
-  private ActiveRuleChange newActiveRuleChance(ActiveRuleChange.Type type, ChangeLog change) {
-    return ActiveRuleChange.createFor(type,
-      ActiveRuleKey.of(change.getProfileKey(), RuleKey.of(change.getRepository(), change.getRuleKey())));
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/ChangeLogMigrationStep.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/ChangeLogMigrationStep.java
new file mode 100644 (file)
index 0000000..9f52b1e
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ * 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.
+ */
+package org.sonar.server.db.migrations.v44;
+
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.commons.lang.StringUtils;
+import org.sonar.api.rule.RuleKey;
+import org.sonar.api.utils.KeyValueFormat;
+import org.sonar.api.utils.internal.Uuids;
+import org.sonar.core.activity.db.ActivityDto;
+import org.sonar.core.persistence.DbSession;
+import org.sonar.core.persistence.migration.v44.ChangeLog;
+import org.sonar.core.persistence.migration.v44.Migration44Mapper;
+import org.sonar.core.qualityprofile.db.ActiveRuleKey;
+import org.sonar.core.rule.SeverityUtil;
+import org.sonar.server.activity.Activity;
+import org.sonar.server.activity.db.ActivityDao;
+import org.sonar.server.db.DbClient;
+import org.sonar.server.db.migrations.MigrationStep;
+import org.sonar.server.qualityprofile.ActiveRuleChange;
+
+/**
+ * SONAR-5329
+ * Transition ActiveRuleChanges to ActivityLog
+ * <p/>
+ * Used in the Active Record Migration 548.
+ *
+ * @since 4.4
+ */
+public class ChangeLogMigrationStep implements MigrationStep {
+
+  private final ActivityDao dao;
+  private final DbClient db;
+
+  public ChangeLogMigrationStep(ActivityDao dao, DbClient db) {
+    this.dao = dao;
+    this.db = db;
+  }
+
+  @Override
+  public void execute() {
+    DbSession session = db.openSession(false);
+    Migration44Mapper migrationMapper = session.getMapper(Migration44Mapper.class);
+    try {
+      executeUpsert(session, ActiveRuleChange.Type.ACTIVATED, migrationMapper.selectActiveRuleChange(true));
+      executeUpsert(session, ActiveRuleChange.Type.UPDATED, migrationMapper.selectActiveRuleChange(null));
+      executeUpsert(session, ActiveRuleChange.Type.DEACTIVATED, migrationMapper.selectActiveRuleChange(false));
+      session.commit();
+    } finally {
+      session.close();
+    }
+  }
+
+  private void executeUpsert(DbSession session, ActiveRuleChange.Type type, List<ChangeLog> changes) {
+
+    Iterator<ChangeLog> changeLogIterator = changes.iterator();
+    if (changeLogIterator.hasNext()) {
+      // startCase
+      ChangeLog change = changeLogIterator.next();
+      int currentId = change.getId();
+      Date currentTimeStamp = change.getCreatedAt();
+      String currentAuthor = change.getUserLogin();
+      ActiveRuleChange ruleChange = newActiveRuleChance(type, change);
+      processRuleChange(ruleChange, change);
+
+      while (changeLogIterator.hasNext()) {
+        change = changeLogIterator.next();
+        int id = change.getId();
+        if (id != currentId) {
+          saveActiveRuleChange(session, ruleChange, currentAuthor, currentTimeStamp);
+          currentId = id;
+          currentTimeStamp = change.getCreatedAt();
+          currentAuthor = change.getUserLogin();
+          ruleChange = newActiveRuleChance(type, change);
+        }
+        processRuleChange(ruleChange, change);
+      }
+      // save the last
+      saveActiveRuleChange(session, ruleChange, currentAuthor, currentTimeStamp);
+    }
+  }
+
+  private void saveActiveRuleChange(DbSession session, ActiveRuleChange ruleChange, String author, Date currentTimeStamp) {
+    Activity activity = ruleChange.toActivity();
+    ActivityDto dto = new ActivityDto();
+    dto.setKey(Uuids.create());
+    dto.setType(Activity.Type.QPROFILE.name());
+    dto.setAction(activity.getAction());
+    dto.setMessage(activity.getMessage());
+    dto.setAuthor(author);
+    dto.setData(KeyValueFormat.format(activity.getData()));
+    dto.setCreatedAt(currentTimeStamp);
+    dao.insert(session, dto);
+  }
+
+  private void processRuleChange(ActiveRuleChange ruleChange, ChangeLog change) {
+    ruleChange.setSeverity(SeverityUtil.getSeverityFromOrdinal(change.getSeverity()));
+    String paramName = change.getParamKey();
+    String paramValue = change.getParamValue();
+    if (StringUtils.isNotEmpty(paramName)) {
+      ruleChange.setParameter(paramName, paramValue);
+    }
+  }
+
+  private ActiveRuleChange newActiveRuleChance(ActiveRuleChange.Type type, ChangeLog change) {
+    return ActiveRuleChange.createFor(type,
+      ActiveRuleKey.of(change.getProfileKey(), RuleKey.of(change.getRepository(), change.getRuleKey())));
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/ConvertProfileMeasuresMigration.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/ConvertProfileMeasuresMigration.java
deleted file mode 100644 (file)
index 994e8f1..0000000
+++ /dev/null
@@ -1,95 +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.
- */
-
-package org.sonar.server.db.migrations.v44;
-
-import org.apache.commons.lang.ObjectUtils;
-import org.sonar.api.utils.text.JsonWriter;
-import org.sonar.core.UtcDateUtils;
-import org.sonar.core.persistence.DbSession;
-import org.sonar.core.persistence.migration.v44.Migration44Mapper;
-import org.sonar.core.persistence.migration.v44.ProfileMeasure;
-import org.sonar.core.persistence.migration.v44.QProfileDto44;
-import org.sonar.server.db.DbClient;
-import org.sonar.server.db.migrations.DatabaseMigration;
-
-import java.io.StringWriter;
-import java.util.Date;
-
-/**
- * Feed the new columns RULES_PROFILE.KEE and PARENT_KEE.
- * 
- * @since 4.4
- */
-public class ConvertProfileMeasuresMigration implements DatabaseMigration {
-
-  private final DbClient db;
-
-  public ConvertProfileMeasuresMigration(DbClient db) {
-    this.db = db;
-  }
-
-  @Override
-  public void execute() {
-    DbSession session = db.openSession(false);
-    try {
-      int i = 0;
-      Date now = new Date();
-      Migration44Mapper mapper = session.getMapper(Migration44Mapper.class);
-      for (ProfileMeasure profileMeasure : mapper.selectProfileMeasures()) {
-        boolean updated = false;
-        Integer version = mapper.selectProfileVersion(profileMeasure.getSnapshotId());
-        QProfileDto44 profile = mapper.selectProfileById(profileMeasure.getProfileId());
-        if (profile != null) {
-          Date date = now;
-          if (version != null) {
-            date = (Date)ObjectUtils.defaultIfNull(
-              mapper.selectProfileVersionDate(profileMeasure.getProfileId(), version), now);
-          }
-          // see format of JSON in org.sonar.batch.rule.UsedQProfiles
-          StringWriter writer = new StringWriter();
-          JsonWriter json = JsonWriter.of(writer);
-          json
-            .beginArray()
-            .beginObject()
-            .prop("key", profile.getKee())
-            .prop("language", profile.getLanguage())
-            .prop("name", profile.getName())
-            .prop("rulesUpdatedAt", UtcDateUtils.formatDateTime(date))
-            .endObject()
-            .endArray()
-            .close();
-          mapper.updateProfileMeasure(profileMeasure.getId(), writer.toString());
-          updated = true;
-        }
-        if (!updated) {
-          mapper.deleteProfileMeasure(profileMeasure.getId());
-        }
-        if (i % 100 == 0) {
-          session.commit();
-          i++;
-        }
-      }
-      session.commit();
-    } finally {
-      session.close();
-    }
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/ConvertProfileMeasuresMigrationStep.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/ConvertProfileMeasuresMigrationStep.java
new file mode 100644 (file)
index 0000000..228c834
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+package org.sonar.server.db.migrations.v44;
+
+import java.io.StringWriter;
+import java.util.Date;
+
+import org.apache.commons.lang.ObjectUtils;
+import org.sonar.api.utils.text.JsonWriter;
+import org.sonar.core.UtcDateUtils;
+import org.sonar.core.persistence.DbSession;
+import org.sonar.core.persistence.migration.v44.Migration44Mapper;
+import org.sonar.core.persistence.migration.v44.ProfileMeasure;
+import org.sonar.core.persistence.migration.v44.QProfileDto44;
+import org.sonar.server.db.DbClient;
+import org.sonar.server.db.migrations.MigrationStep;
+
+/**
+ * Feed the new columns RULES_PROFILE.KEE and PARENT_KEE.
+ * 
+ * @since 4.4
+ */
+public class ConvertProfileMeasuresMigrationStep implements MigrationStep {
+
+  private final DbClient db;
+
+  public ConvertProfileMeasuresMigrationStep(DbClient db) {
+    this.db = db;
+  }
+
+  @Override
+  public void execute() {
+    DbSession session = db.openSession(false);
+    try {
+      int i = 0;
+      Date now = new Date();
+      Migration44Mapper mapper = session.getMapper(Migration44Mapper.class);
+      for (ProfileMeasure profileMeasure : mapper.selectProfileMeasures()) {
+        boolean updated = false;
+        Integer version = mapper.selectProfileVersion(profileMeasure.getSnapshotId());
+        QProfileDto44 profile = mapper.selectProfileById(profileMeasure.getProfileId());
+        if (profile != null) {
+          Date date = now;
+          if (version != null) {
+            date = (Date) ObjectUtils.defaultIfNull(
+              mapper.selectProfileVersionDate(profileMeasure.getProfileId(), version), now);
+          }
+          // see format of JSON in org.sonar.batch.rule.UsedQProfiles
+          StringWriter writer = new StringWriter();
+          JsonWriter json = JsonWriter.of(writer);
+          json
+            .beginArray()
+            .beginObject()
+            .prop("key", profile.getKee())
+            .prop("language", profile.getLanguage())
+            .prop("name", profile.getName())
+            .prop("rulesUpdatedAt", UtcDateUtils.formatDateTime(date))
+            .endObject()
+            .endArray()
+            .close();
+          mapper.updateProfileMeasure(profileMeasure.getId(), writer.toString());
+          updated = true;
+        }
+        if (!updated) {
+          mapper.deleteProfileMeasure(profileMeasure.getId());
+        }
+        if (i % 100 == 0) {
+          session.commit();
+          i++;
+        }
+      }
+      session.commit();
+    } finally {
+      session.close();
+    }
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/FeedQProfileDatesMigration.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/FeedQProfileDatesMigration.java
deleted file mode 100644 (file)
index 24a52f1..0000000
+++ /dev/null
@@ -1,71 +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.
- */
-
-package org.sonar.server.db.migrations.v44;
-
-import org.apache.commons.lang.ObjectUtils;
-import org.sonar.api.utils.System2;
-import org.sonar.core.UtcDateUtils;
-import org.sonar.core.persistence.DbSession;
-import org.sonar.core.persistence.migration.v44.Migration44Mapper;
-import org.sonar.core.persistence.migration.v44.QProfileDto44;
-import org.sonar.server.db.DbClient;
-import org.sonar.server.db.migrations.DatabaseMigration;
-
-import java.util.Date;
-
-/**
- * Feed the new columns RULES_PROFILES.CREATED_AT and UPDATED_AT
- * 
- * @since 4.4
- */
-public class FeedQProfileDatesMigration implements DatabaseMigration {
-
-  private final DbClient db;
-  private final System2 system;
-
-  public FeedQProfileDatesMigration(DbClient db, System2 system) {
-    this.db = db;
-    this.system = system;
-  }
-
-  @Override
-  public void execute() {
-    DbSession session = db.openSession(false);
-    try {
-      Date now = new Date(system.now());
-      int i = 0;
-      Migration44Mapper migrationMapper = session.getMapper(Migration44Mapper.class);
-      for (QProfileDto44 profile : migrationMapper.selectAllProfiles()) {
-        Date createdAt = (Date) ObjectUtils.defaultIfNull(migrationMapper.selectProfileCreatedAt(profile.getId()), now);
-        Date updatedAt = (Date) ObjectUtils.defaultIfNull(migrationMapper.selectProfileUpdatedAt(profile.getId()), now);
-
-        migrationMapper.updateProfileDates(profile.getId(), createdAt, updatedAt, UtcDateUtils.formatDateTime(updatedAt));
-        if (i % 100 == 0) {
-          session.commit();
-          i++;
-        }
-      }
-      session.commit();
-    } finally {
-      session.close();
-    }
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/FeedQProfileDatesMigrationStep.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/FeedQProfileDatesMigrationStep.java
new file mode 100644 (file)
index 0000000..7ca01fa
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * 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.
+ */
+
+package org.sonar.server.db.migrations.v44;
+
+import java.util.Date;
+
+import org.apache.commons.lang.ObjectUtils;
+import org.sonar.api.utils.System2;
+import org.sonar.core.UtcDateUtils;
+import org.sonar.core.persistence.DbSession;
+import org.sonar.core.persistence.migration.v44.Migration44Mapper;
+import org.sonar.core.persistence.migration.v44.QProfileDto44;
+import org.sonar.server.db.DbClient;
+import org.sonar.server.db.migrations.MigrationStep;
+
+/**
+ * Feed the new columns RULES_PROFILES.CREATED_AT and UPDATED_AT
+ * 
+ * @since 4.4
+ */
+public class FeedQProfileDatesMigrationStep implements MigrationStep {
+
+  private final DbClient db;
+  private final System2 system;
+
+  public FeedQProfileDatesMigrationStep(DbClient db, System2 system) {
+    this.db = db;
+    this.system = system;
+  }
+
+  @Override
+  public void execute() {
+    DbSession session = db.openSession(false);
+    try {
+      Date now = new Date(system.now());
+      int i = 0;
+      Migration44Mapper migrationMapper = session.getMapper(Migration44Mapper.class);
+      for (QProfileDto44 profile : migrationMapper.selectAllProfiles()) {
+        Date createdAt = (Date) ObjectUtils.defaultIfNull(migrationMapper.selectProfileCreatedAt(profile.getId()), now);
+        Date updatedAt = (Date) ObjectUtils.defaultIfNull(migrationMapper.selectProfileUpdatedAt(profile.getId()), now);
+
+        migrationMapper.updateProfileDates(profile.getId(), createdAt, updatedAt, UtcDateUtils.formatDateTime(updatedAt));
+        if (i % 100 == 0) {
+          session.commit();
+          i++;
+        }
+      }
+      session.commit();
+    } finally {
+      session.close();
+    }
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/FeedQProfileKeysMigration.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/FeedQProfileKeysMigration.java
deleted file mode 100644 (file)
index 90c9ed8..0000000
+++ /dev/null
@@ -1,87 +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.
- */
-
-package org.sonar.server.db.migrations.v44;
-
-import org.apache.commons.lang.RandomStringUtils;
-import org.sonar.core.persistence.Database;
-import org.sonar.server.db.migrations.BaseDataChange;
-import org.sonar.server.db.migrations.MassUpdate;
-import org.sonar.server.db.migrations.Select;
-import org.sonar.server.db.migrations.SqlStatement;
-import org.sonar.server.util.Slug;
-
-import java.sql.SQLException;
-
-/**
- * Feed the new columns RULES_PROFILES.KEE and PARENT_KEE.
- * 
- * @since 4.4
- */
-public class FeedQProfileKeysMigration extends BaseDataChange {
-
-  public FeedQProfileKeysMigration(Database db) {
-    super(db);
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    updateKeys(context);
-    updateParentKeys(context);
-  }
-
-  private void updateKeys(Context context) throws SQLException {
-    MassUpdate massUpdate = context.prepareMassUpdate();
-    massUpdate.select("SELECT id,language,name FROM rules_profiles");
-    massUpdate.update("UPDATE rules_profiles SET kee=? WHERE id=?");
-    massUpdate.rowPluralName("profiles");
-    massUpdate.execute(new MassUpdate.Handler() {
-      @Override
-      public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
-        Long id = row.getNullableLong(1);
-        String lang = row.getNullableString(2);
-        String name = row.getNullableString(3);
-
-        update.setString(1, Slug.slugify(String.format("%s %s %s", lang, name, RandomStringUtils.randomNumeric(5))));
-        update.setLong(2, id);
-        return true;
-      }
-    });
-  }
-
-  private void updateParentKeys(Context context) throws SQLException {
-    MassUpdate massUpdate = context.prepareMassUpdate();
-    massUpdate.select("SELECT child.id,parent.kee FROM rules_profiles child, rules_profiles parent WHERE child.parent_name=parent.name " +
-      "and child.language=parent.language AND child.parent_name IS NOT NULL");
-    massUpdate.update("UPDATE rules_profiles SET parent_kee=? WHERE id=?");
-    massUpdate.execute(new MassUpdate.Handler() {
-      @Override
-      public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
-        Long id = row.getNullableLong(1);
-        String parentKey = row.getNullableString(2);
-
-        update.setString(1, parentKey);
-        update.setLong(2, id);
-        return true;
-      }
-    });
-
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/FeedQProfileKeysMigrationStep.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/FeedQProfileKeysMigrationStep.java
new file mode 100644 (file)
index 0000000..7e98134
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * 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.
+ */
+
+package org.sonar.server.db.migrations.v44;
+
+import java.sql.SQLException;
+
+import org.apache.commons.lang.RandomStringUtils;
+import org.sonar.core.persistence.Database;
+import org.sonar.server.db.migrations.BaseDataChange;
+import org.sonar.server.db.migrations.MassUpdate;
+import org.sonar.server.db.migrations.Select;
+import org.sonar.server.db.migrations.SqlStatement;
+import org.sonar.server.util.Slug;
+
+/**
+ * Feed the new columns RULES_PROFILES.KEE and PARENT_KEE.
+ * 
+ * @since 4.4
+ */
+public class FeedQProfileKeysMigrationStep extends BaseDataChange {
+
+  public FeedQProfileKeysMigrationStep(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    updateKeys(context);
+    updateParentKeys(context);
+  }
+
+  private void updateKeys(Context context) throws SQLException {
+    MassUpdate massUpdate = context.prepareMassUpdate();
+    massUpdate.select("SELECT id,language,name FROM rules_profiles");
+    massUpdate.update("UPDATE rules_profiles SET kee=? WHERE id=?");
+    massUpdate.rowPluralName("profiles");
+    massUpdate.execute(new MassUpdate.Handler() {
+      @Override
+      public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
+        Long id = row.getNullableLong(1);
+        String lang = row.getNullableString(2);
+        String name = row.getNullableString(3);
+
+        update.setString(1, Slug.slugify(String.format("%s %s %s", lang, name, RandomStringUtils.randomNumeric(5))));
+        update.setLong(2, id);
+        return true;
+      }
+    });
+  }
+
+  private void updateParentKeys(Context context) throws SQLException {
+    MassUpdate massUpdate = context.prepareMassUpdate();
+    massUpdate.select("SELECT child.id,parent.kee FROM rules_profiles child, rules_profiles parent WHERE child.parent_name=parent.name " +
+      "and child.language=parent.language AND child.parent_name IS NOT NULL");
+    massUpdate.update("UPDATE rules_profiles SET parent_kee=? WHERE id=?");
+    massUpdate.execute(new MassUpdate.Handler() {
+      @Override
+      public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
+        Long id = row.getNullableLong(1);
+        String parentKey = row.getNullableString(2);
+
+        update.setString(1, parentKey);
+        update.setLong(2, id);
+        return true;
+      }
+    });
+
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/IssueActionPlanKeyMigration.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/IssueActionPlanKeyMigration.java
deleted file mode 100644 (file)
index 9adad2d..0000000
+++ /dev/null
@@ -1,70 +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.
- */
-
-package org.sonar.server.db.migrations.v44;
-
-import org.sonar.api.utils.System2;
-import org.sonar.core.persistence.Database;
-import org.sonar.server.db.migrations.BaseDataChange;
-import org.sonar.server.db.migrations.MassUpdate;
-import org.sonar.server.db.migrations.Select;
-import org.sonar.server.db.migrations.SqlStatement;
-
-import java.sql.SQLException;
-import java.util.Date;
-
-/**
- * SONAR-5218
- * Update all issues having action plan linked on removed action plan.
- * <p/>
- * Used in the Active Record Migration 531.
- *
- * @since 4.4
- */
-public class IssueActionPlanKeyMigration extends BaseDataChange {
-
-  private final System2 system2;
-
-  public IssueActionPlanKeyMigration(Database database, System2 system2) {
-    super(database);
-    this.system2 = system2;
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    final Date now = new Date(system2.now());
-    MassUpdate massUpdate = context.prepareMassUpdate();
-    massUpdate.select("SELECT i.id FROM issues i " +
-      "LEFT OUTER JOIN action_plans ap ON ap.kee=i.action_plan_key " +
-      "WHERE i.action_plan_key IS NOT NULL " +
-      "AND ap.kee is null");
-    massUpdate.update("UPDATE issues SET action_plan_key=NULL,updated_at=? WHERE id=?");
-    massUpdate.execute(new MassUpdate.Handler() {
-      @Override
-      public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
-        Long id = row.getNullableLong(1);
-
-        update.setDate(1, now);
-        update.setLong(2, id);
-        return true;
-      }
-    });
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/IssueActionPlanKeyMigrationStep.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/IssueActionPlanKeyMigrationStep.java
new file mode 100644 (file)
index 0000000..4083015
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
+
+package org.sonar.server.db.migrations.v44;
+
+import java.sql.SQLException;
+import java.util.Date;
+
+import org.sonar.api.utils.System2;
+import org.sonar.core.persistence.Database;
+import org.sonar.server.db.migrations.BaseDataChange;
+import org.sonar.server.db.migrations.MassUpdate;
+import org.sonar.server.db.migrations.Select;
+import org.sonar.server.db.migrations.SqlStatement;
+
+/**
+ * SONAR-5218
+ * Update all issues having action plan linked on removed action plan.
+ * <p/>
+ * Used in the Active Record Migration 531.
+ *
+ * @since 4.4
+ */
+public class IssueActionPlanKeyMigrationStep extends BaseDataChange {
+
+  private final System2 system2;
+
+  public IssueActionPlanKeyMigrationStep(Database database, System2 system2) {
+    super(database);
+    this.system2 = system2;
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    final Date now = new Date(system2.now());
+    MassUpdate massUpdate = context.prepareMassUpdate();
+    massUpdate.select("SELECT i.id FROM issues i " +
+      "LEFT OUTER JOIN action_plans ap ON ap.kee=i.action_plan_key " +
+      "WHERE i.action_plan_key IS NOT NULL " +
+      "AND ap.kee is null");
+    massUpdate.update("UPDATE issues SET action_plan_key=NULL,updated_at=? WHERE id=?");
+    massUpdate.execute(new MassUpdate.Handler() {
+      @Override
+      public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
+        Long id = row.getNullableLong(1);
+
+        update.setDate(1, now);
+        update.setLong(2, id);
+        return true;
+      }
+    });
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/MeasureDataMigration.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/MeasureDataMigration.java
deleted file mode 100644 (file)
index 23ecb4c..0000000
+++ /dev/null
@@ -1,63 +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.
- */
-
-package org.sonar.server.db.migrations.v44;
-
-import org.sonar.core.persistence.Database;
-import org.sonar.server.db.migrations.BaseDataChange;
-import org.sonar.server.db.migrations.MassUpdate;
-import org.sonar.server.db.migrations.Select;
-import org.sonar.server.db.migrations.SqlStatement;
-
-import java.sql.SQLException;
-
-/**
- * SONAR-5249
- * Merge measure data table into project_measure
- *
- * Used in the Active Record Migration 530.
- * @since 4.4
- */
-public class MeasureDataMigration extends BaseDataChange {
-
-  public MeasureDataMigration(Database database) {
-    super(database);
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    MassUpdate massUpdate = context.prepareMassUpdate();
-    massUpdate.rowPluralName("measures");
-    massUpdate.select("select md.id, md.measure_id FROM measure_data md " +
-      "inner join project_measures m on m.id=md.measure_id and m.measure_data is null");
-    massUpdate.update("update project_measures SET measure_data = (SELECT md.data FROM measure_data md WHERE md.id = ?) WHERE id=?");
-    massUpdate.execute(new MassUpdate.Handler() {
-      @Override
-      public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
-        Long id = row.getNullableLong(1);
-        Long measureId = row.getNullableLong(2);
-
-        update.setLong(1, id);
-        update.setLong(2, measureId);
-        return true;
-      }
-    });
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/MeasureDataMigrationStep.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/MeasureDataMigrationStep.java
new file mode 100644 (file)
index 0000000..b48870d
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ */
+
+package org.sonar.server.db.migrations.v44;
+
+import java.sql.SQLException;
+
+import org.sonar.core.persistence.Database;
+import org.sonar.server.db.migrations.BaseDataChange;
+import org.sonar.server.db.migrations.MassUpdate;
+import org.sonar.server.db.migrations.Select;
+import org.sonar.server.db.migrations.SqlStatement;
+
+/**
+ * SONAR-5249
+ * Merge measure data table into project_measure
+ *
+ * Used in the Active Record Migration 530.
+ * @since 4.4
+ */
+public class MeasureDataMigrationStep extends BaseDataChange {
+
+  public MeasureDataMigrationStep(Database database) {
+    super(database);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    MassUpdate massUpdate = context.prepareMassUpdate();
+    massUpdate.rowPluralName("measures");
+    massUpdate.select("select md.id, md.measure_id FROM measure_data md " +
+      "inner join project_measures m on m.id=md.measure_id and m.measure_data is null");
+    massUpdate.update("update project_measures SET measure_data = (SELECT md.data FROM measure_data md WHERE md.id = ?) WHERE id=?");
+    massUpdate.execute(new MassUpdate.Handler() {
+      @Override
+      public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
+        Long id = row.getNullableLong(1);
+        Long measureId = row.getNullableLong(2);
+
+        update.setLong(1, id);
+        update.setLong(2, measureId);
+        return true;
+      }
+    });
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v45/AddMissingRuleParameterDefaultValuesMigration.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v45/AddMissingRuleParameterDefaultValuesMigration.java
deleted file mode 100644 (file)
index 02b02f8..0000000
+++ /dev/null
@@ -1,118 +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.
- */
-package org.sonar.server.db.migrations.v45;
-
-import org.sonar.api.utils.System2;
-import org.sonar.core.persistence.Database;
-import org.sonar.server.db.migrations.BaseDataChange;
-import org.sonar.server.db.migrations.Select;
-import org.sonar.server.db.migrations.Upsert;
-
-import javax.annotation.Nullable;
-
-import java.sql.SQLException;
-import java.util.Date;
-import java.util.List;
-
-/**
- * SONAR-5446
- */
-public class AddMissingRuleParameterDefaultValuesMigration extends BaseDataChange {
-
-  private final System2 system;
-
-  public AddMissingRuleParameterDefaultValuesMigration(Database db, System2 system) {
-    super(db);
-    this.system = system;
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    // get all the parameters with default value
-    List<RuleParam> ruleParameters = context.prepareSelect("select id,rule_id,name,default_value from rules_parameters where default_value is not null")
-      .list(new Select.RowReader<RuleParam>() {
-        @Override
-        public RuleParam read(Select.Row row) throws SQLException {
-          return new RuleParam(row.getNullableLong(1), row.getNullableLong(2), row.getNullableString(3), row.getNullableString(4));
-        }
-      });
-
-    for (RuleParam ruleParameter : ruleParameters) {
-      List<ActiveRule> activeRules = context.prepareSelect("select ar.id, ar.profile_id from active_rules ar " +
-        "left outer join active_rule_parameters arp on arp.active_rule_id=ar.id and arp.rules_parameter_id=? " +
-        "where ar.rule_id=? and arp.id is null")
-        .setLong(1, ruleParameter.id)
-        .setLong(2, ruleParameter.ruleId)
-        .list(new Select.RowReader<ActiveRule>() {
-          @Override
-          public ActiveRule read(Select.Row row) throws SQLException {
-            return new ActiveRule(row.getNullableLong(1), row.getNullableLong(2));
-          }
-        });
-
-      Upsert upsert = context.prepareUpsert("insert into active_rule_parameters(active_rule_id, rules_parameter_id, value, rules_parameter_key) values (?, ?, ?, ?)");
-      for (ActiveRule activeRule : activeRules) {
-        upsert
-          .setLong(1, activeRule.id)
-          .setLong(2, ruleParameter.id)
-          .setString(3, ruleParameter.defaultValue)
-          .setString(4, ruleParameter.name)
-          .addBatch();
-      }
-      if (!activeRules.isEmpty()) {
-        upsert.execute().commit().close();
-      }
-
-      // update date for ES indexation
-      upsert = context.prepareUpsert("update active_rules set updated_at=? where id=?");
-      Date now = new Date(system.now());
-      for (ActiveRule activeRule : activeRules) {
-        upsert
-          .setDate(1, now)
-          .setLong(2, activeRule.id)
-          .addBatch();
-      }
-      if (!activeRules.isEmpty()) {
-        upsert.execute().commit().close();
-      }
-    }
-  }
-
-  private static class RuleParam {
-    final Long id, ruleId;
-    final String defaultValue, name;
-
-    RuleParam(@Nullable Long id, @Nullable Long ruleId, @Nullable String name, @Nullable String defaultValue) {
-      this.id = id;
-      this.ruleId = ruleId;
-      this.name = name;
-      this.defaultValue = defaultValue;
-    }
-  }
-
-  private static class ActiveRule {
-    final Long id, profileId;
-
-    ActiveRule(@Nullable Long id, @Nullable Long profileId) {
-      this.id = id;
-      this.profileId = profileId;
-    }
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v45/AddMissingRuleParameterDefaultValuesMigrationStep.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v45/AddMissingRuleParameterDefaultValuesMigrationStep.java
new file mode 100644 (file)
index 0000000..0000e54
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * 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.
+ */
+package org.sonar.server.db.migrations.v45;
+
+import java.sql.SQLException;
+import java.util.Date;
+import java.util.List;
+
+import javax.annotation.Nullable;
+
+import org.sonar.api.utils.System2;
+import org.sonar.core.persistence.Database;
+import org.sonar.server.db.migrations.BaseDataChange;
+import org.sonar.server.db.migrations.Select;
+import org.sonar.server.db.migrations.Upsert;
+
+/**
+ * SONAR-5446
+ */
+public class AddMissingRuleParameterDefaultValuesMigrationStep extends BaseDataChange {
+
+  private final System2 system;
+
+  public AddMissingRuleParameterDefaultValuesMigrationStep(Database db, System2 system) {
+    super(db);
+    this.system = system;
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    // get all the parameters with default value
+    List<RuleParam> ruleParameters = context.prepareSelect("select id,rule_id,name,default_value from rules_parameters where default_value is not null")
+      .list(new Select.RowReader<RuleParam>() {
+        @Override
+        public RuleParam read(Select.Row row) throws SQLException {
+          return new RuleParam(row.getNullableLong(1), row.getNullableLong(2), row.getNullableString(3), row.getNullableString(4));
+        }
+      });
+
+    for (RuleParam ruleParameter : ruleParameters) {
+      List<ActiveRule> activeRules = context.prepareSelect("select ar.id, ar.profile_id from active_rules ar " +
+        "left outer join active_rule_parameters arp on arp.active_rule_id=ar.id and arp.rules_parameter_id=? " +
+        "where ar.rule_id=? and arp.id is null")
+        .setLong(1, ruleParameter.id)
+        .setLong(2, ruleParameter.ruleId)
+        .list(new Select.RowReader<ActiveRule>() {
+          @Override
+          public ActiveRule read(Select.Row row) throws SQLException {
+            return new ActiveRule(row.getNullableLong(1), row.getNullableLong(2));
+          }
+        });
+
+      Upsert upsert = context.prepareUpsert("insert into active_rule_parameters(active_rule_id, rules_parameter_id, value, rules_parameter_key) values (?, ?, ?, ?)");
+      for (ActiveRule activeRule : activeRules) {
+        upsert
+          .setLong(1, activeRule.id)
+          .setLong(2, ruleParameter.id)
+          .setString(3, ruleParameter.defaultValue)
+          .setString(4, ruleParameter.name)
+          .addBatch();
+      }
+      if (!activeRules.isEmpty()) {
+        upsert.execute().commit().close();
+      }
+
+      // update date for ES indexation
+      upsert = context.prepareUpsert("update active_rules set updated_at=? where id=?");
+      Date now = new Date(system.now());
+      for (ActiveRule activeRule : activeRules) {
+        upsert
+          .setDate(1, now)
+          .setLong(2, activeRule.id)
+          .addBatch();
+      }
+      if (!activeRules.isEmpty()) {
+        upsert.execute().commit().close();
+      }
+    }
+  }
+
+  private static class RuleParam {
+    final Long id, ruleId;
+    final String defaultValue, name;
+
+    RuleParam(@Nullable Long id, @Nullable Long ruleId, @Nullable String name, @Nullable String defaultValue) {
+      this.id = id;
+      this.ruleId = ruleId;
+      this.name = name;
+      this.defaultValue = defaultValue;
+    }
+  }
+
+  private static class ActiveRule {
+    final Long id, profileId;
+
+    ActiveRule(@Nullable Long id, @Nullable Long profileId) {
+      this.id = id;
+      this.profileId = profileId;
+    }
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v45/DeleteMeasuresOnDeletedProfilesMigration.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v45/DeleteMeasuresOnDeletedProfilesMigration.java
deleted file mode 100644 (file)
index 0a79bd6..0000000
+++ /dev/null
@@ -1,59 +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.
- */
-
-package org.sonar.server.db.migrations.v45;
-
-import org.sonar.core.persistence.DbSession;
-import org.sonar.core.persistence.migration.v44.Migration44Mapper;
-import org.sonar.server.db.DbClient;
-import org.sonar.server.db.migrations.DatabaseMigration;
-
-/**
- * See http://jira.codehaus.org/browse/SONAR-5580
- * {@link org.sonar.server.db.migrations.v44.ConvertProfileMeasuresMigration} 
- * introduced a regression in 4.4. Measures on orphan profiles were kept 
- * in old format (no JSON data but numeric value of profile id)
- * 
- * @see org.sonar.server.db.migrations.v44.ConvertProfileMeasuresMigration
- * @since 4.5
- */
-public class DeleteMeasuresOnDeletedProfilesMigration implements DatabaseMigration {
-
-  private final DbClient db;
-
-  public DeleteMeasuresOnDeletedProfilesMigration(DbClient db) {
-    this.db = db;
-  }
-
-  @Override
-  public void execute() {
-    DbSession session = db.openSession(false);
-    try {
-      Migration44Mapper mapper = session.getMapper(Migration44Mapper.class);
-      for (Long measureId : mapper.selectMeasuresOnDeletedQualityProfiles()) {
-        mapper.deleteProfileMeasure(measureId);
-      }
-      session.commit();
-
-    } finally {
-      session.close();
-    }
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v45/DeleteMeasuresOnDeletedProfilesMigrationStep.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v45/DeleteMeasuresOnDeletedProfilesMigrationStep.java
new file mode 100644 (file)
index 0000000..b61c62a
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+
+package org.sonar.server.db.migrations.v45;
+
+import org.sonar.core.persistence.DbSession;
+import org.sonar.core.persistence.migration.v44.Migration44Mapper;
+import org.sonar.server.db.DbClient;
+import org.sonar.server.db.migrations.MigrationStep;
+import org.sonar.server.db.migrations.v44.ConvertProfileMeasuresMigrationStep;
+
+/**
+ * See http://jira.codehaus.org/browse/SONAR-5580
+ * {@link ConvertProfileMeasuresMigrationStep}
+ * introduced a regression in 4.4. Measures on orphan profiles were kept 
+ * in old format (no JSON data but numeric value of profile id)
+ * 
+ * @see ConvertProfileMeasuresMigrationStep
+ * @since 4.5
+ */
+public class DeleteMeasuresOnDeletedProfilesMigrationStep implements MigrationStep {
+
+  private final DbClient db;
+
+  public DeleteMeasuresOnDeletedProfilesMigrationStep(DbClient db) {
+    this.db = db;
+  }
+
+  @Override
+  public void execute() {
+    DbSession session = db.openSession(false);
+    try {
+      Migration44Mapper mapper = session.getMapper(Migration44Mapper.class);
+      for (Long measureId : mapper.selectMeasuresOnDeletedQualityProfiles()) {
+        mapper.deleteProfileMeasure(measureId);
+      }
+      session.commit();
+
+    } finally {
+      session.close();
+    }
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v451/AddMissingCustomRuleParametersMigration.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v451/AddMissingCustomRuleParametersMigration.java
deleted file mode 100644 (file)
index 5d87dc3..0000000
+++ /dev/null
@@ -1,137 +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.
- */
-package org.sonar.server.db.migrations.v451;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Multimap;
-import org.sonar.api.utils.System2;
-import org.sonar.core.persistence.DbSession;
-import org.sonar.core.persistence.migration.v45.Migration45Mapper;
-import org.sonar.core.persistence.migration.v45.Rule;
-import org.sonar.core.persistence.migration.v45.RuleParameter;
-import org.sonar.server.db.DbClient;
-import org.sonar.server.db.migrations.DatabaseMigration;
-import org.sonar.server.util.ProgressLogger;
-
-import javax.annotation.Nullable;
-
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicLong;
-
-/**
- * See http://jira.codehaus.org/browse/SONAR-5575
- *
- * Add missing parameters (with no value) on each custom rules
- *
- * @since 4.5.1
- */
-public class AddMissingCustomRuleParametersMigration implements DatabaseMigration {
-
-  private final DbClient db;
-  private final System2 system;
-  private final AtomicLong counter = new AtomicLong(0L);
-
-  public AddMissingCustomRuleParametersMigration(DbClient db, System2 system) {
-    this.db = db;
-    this.system = system;
-  }
-
-  @Override
-  public void execute() {
-    ProgressLogger progress = ProgressLogger.create(getClass(), counter);
-    progress.start();
-
-    DbSession session = db.openSession(false);
-    try {
-      Migration45Mapper mapper = session.getMapper(Migration45Mapper.class);
-
-      List<RuleParameter> templateRuleParams = mapper.selectAllTemplateRuleParameters();
-      Multimap<Integer, RuleParameter> templateRuleParamsByRuleId = ArrayListMultimap.create();
-      for (RuleParameter templateRuleParam : templateRuleParams) {
-        templateRuleParamsByRuleId.put(templateRuleParam.getRuleId(), templateRuleParam);
-      }
-
-      List<Rule> customRules = mapper.selectAllCustomRules();
-      Multimap<Integer, Integer> customRuleIdsByTemplateRuleId = HashMultimap.create();
-      for (Rule customRule : customRules) {
-        customRuleIdsByTemplateRuleId.put(customRule.getTemplateId(), customRule.getId());
-      }
-
-      List<RuleParameter> customRuleParams = mapper.selectAllCustomRuleParameters();
-      Multimap<Integer, RuleParameter> customRuleParamsByRuleId = ArrayListMultimap.create();
-      for (RuleParameter customRuleParam : customRuleParams) {
-        customRuleParamsByRuleId.put(customRuleParam.getRuleId(), customRuleParam);
-      }
-
-      // For each parameters of template rules, verify that each custom rules has the parameter
-      for (Integer templateRuleId : templateRuleParamsByRuleId.keySet()) {
-        for (RuleParameter templateRuleParam : templateRuleParamsByRuleId.get(templateRuleId)) {
-          // Each custom rule should have this parameter
-          insertCustomRuleParameterIfNotAlreadyExisting(templateRuleParam, templateRuleId, customRuleIdsByTemplateRuleId, customRuleParamsByRuleId, session);
-        }
-      }
-
-      session.commit();
-
-      // log the total number of process rows
-      progress.log();
-    } finally {
-      session.close();
-      progress.stop();
-    }
-  }
-
-  private void insertCustomRuleParameterIfNotAlreadyExisting(RuleParameter templateRuleParam, Integer templateRuleId,
-    Multimap<Integer, Integer> customRuleIdsByTemplateRuleId,
-    Multimap<Integer, RuleParameter> customRuleParamsByRuleId,
-    DbSession session) {
-    for (Integer customRuleId : customRuleIdsByTemplateRuleId.get(templateRuleId)) {
-      if (!hasParameter(templateRuleParam.getName(), customRuleParamsByRuleId.get(customRuleId))) {
-        // Insert new custom rule parameter
-        session.getMapper(Migration45Mapper.class).insertRuleParameter(new RuleParameter()
-          .setRuleId(customRuleId)
-          .setRuleTemplateId(templateRuleId)
-          .setName(templateRuleParam.getName())
-          .setDescription(templateRuleParam.getDescription())
-          .setType(templateRuleParam.getType())
-          );
-
-        // Update updated at date of custom rule in order to allow E/S indexation
-        session.getMapper(Migration45Mapper.class).updateRuleUpdateAt(customRuleId, new Date(system.now()));
-
-        counter.getAndIncrement();
-      }
-    }
-  }
-
-  private boolean hasParameter(final String parameter, Collection<RuleParameter> customRuleParams) {
-    return Iterables.any(customRuleParams, new Predicate<RuleParameter>() {
-      @Override
-      public boolean apply(@Nullable RuleParameter input) {
-        return input != null && input.getName().equals(parameter);
-      }
-    });
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v451/AddMissingCustomRuleParametersMigrationStep.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v451/AddMissingCustomRuleParametersMigrationStep.java
new file mode 100644 (file)
index 0000000..55e2681
--- /dev/null
@@ -0,0 +1,138 @@
+/*
+ * 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.
+ */
+package org.sonar.server.db.migrations.v451;
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
+
+import javax.annotation.Nullable;
+
+import org.sonar.api.utils.System2;
+import org.sonar.core.persistence.DbSession;
+import org.sonar.core.persistence.migration.v45.Migration45Mapper;
+import org.sonar.core.persistence.migration.v45.Rule;
+import org.sonar.core.persistence.migration.v45.RuleParameter;
+import org.sonar.server.db.DbClient;
+import org.sonar.server.db.migrations.MigrationStep;
+import org.sonar.server.util.ProgressLogger;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Multimap;
+
+/**
+ * See http://jira.codehaus.org/browse/SONAR-5575
+ *
+ * Add missing parameters (with no value) on each custom rules
+ *
+ * @since 4.5.1
+ */
+public class AddMissingCustomRuleParametersMigrationStep implements MigrationStep {
+
+  private final DbClient db;
+  private final System2 system;
+  private final AtomicLong counter = new AtomicLong(0L);
+
+  public AddMissingCustomRuleParametersMigrationStep(DbClient db, System2 system) {
+    this.db = db;
+    this.system = system;
+  }
+
+  @Override
+  public void execute() {
+    ProgressLogger progress = ProgressLogger.create(getClass(), counter);
+    progress.start();
+
+    DbSession session = db.openSession(false);
+    try {
+      Migration45Mapper mapper = session.getMapper(Migration45Mapper.class);
+
+      List<RuleParameter> templateRuleParams = mapper.selectAllTemplateRuleParameters();
+      Multimap<Integer, RuleParameter> templateRuleParamsByRuleId = ArrayListMultimap.create();
+      for (RuleParameter templateRuleParam : templateRuleParams) {
+        templateRuleParamsByRuleId.put(templateRuleParam.getRuleId(), templateRuleParam);
+      }
+
+      List<Rule> customRules = mapper.selectAllCustomRules();
+      Multimap<Integer, Integer> customRuleIdsByTemplateRuleId = HashMultimap.create();
+      for (Rule customRule : customRules) {
+        customRuleIdsByTemplateRuleId.put(customRule.getTemplateId(), customRule.getId());
+      }
+
+      List<RuleParameter> customRuleParams = mapper.selectAllCustomRuleParameters();
+      Multimap<Integer, RuleParameter> customRuleParamsByRuleId = ArrayListMultimap.create();
+      for (RuleParameter customRuleParam : customRuleParams) {
+        customRuleParamsByRuleId.put(customRuleParam.getRuleId(), customRuleParam);
+      }
+
+      // For each parameters of template rules, verify that each custom rules has the parameter
+      for (Integer templateRuleId : templateRuleParamsByRuleId.keySet()) {
+        for (RuleParameter templateRuleParam : templateRuleParamsByRuleId.get(templateRuleId)) {
+          // Each custom rule should have this parameter
+          insertCustomRuleParameterIfNotAlreadyExisting(templateRuleParam, templateRuleId, customRuleIdsByTemplateRuleId, customRuleParamsByRuleId, session);
+        }
+      }
+
+      session.commit();
+
+      // log the total number of process rows
+      progress.log();
+    } finally {
+      session.close();
+      progress.stop();
+    }
+  }
+
+  private void insertCustomRuleParameterIfNotAlreadyExisting(RuleParameter templateRuleParam, Integer templateRuleId,
+    Multimap<Integer, Integer> customRuleIdsByTemplateRuleId,
+    Multimap<Integer, RuleParameter> customRuleParamsByRuleId,
+    DbSession session) {
+    for (Integer customRuleId : customRuleIdsByTemplateRuleId.get(templateRuleId)) {
+      if (!hasParameter(templateRuleParam.getName(), customRuleParamsByRuleId.get(customRuleId))) {
+        // Insert new custom rule parameter
+        session.getMapper(Migration45Mapper.class).insertRuleParameter(new RuleParameter()
+          .setRuleId(customRuleId)
+          .setRuleTemplateId(templateRuleId)
+          .setName(templateRuleParam.getName())
+          .setDescription(templateRuleParam.getDescription())
+          .setType(templateRuleParam.getType())
+          );
+
+        // Update updated at date of custom rule in order to allow E/S indexation
+        session.getMapper(Migration45Mapper.class).updateRuleUpdateAt(customRuleId, new Date(system.now()));
+
+        counter.getAndIncrement();
+      }
+    }
+  }
+
+  private boolean hasParameter(final String parameter, Collection<RuleParameter> customRuleParams) {
+    return Iterables.any(customRuleParams, new Predicate<RuleParameter>() {
+      @Override
+      public boolean apply(@Nullable RuleParameter input) {
+        return input != null && input.getName().equals(parameter);
+      }
+    });
+  }
+}
index 49c50bc09809b134eb7e2bf9201f045c9f46c2ea..234867cbb3c3f0defc82626e3571e9cdd6982377 100644 (file)
  */
 package org.sonar.server.db.migrations.v451;
 
+import java.sql.SQLException;
+
+import javax.annotation.Nullable;
+
 import org.apache.commons.lang.StringUtils;
 import org.sonar.core.persistence.Database;
 import org.sonar.server.db.migrations.BaseDataChange;
@@ -26,10 +30,6 @@ import org.sonar.server.db.migrations.MassUpdate;
 import org.sonar.server.db.migrations.Select;
 import org.sonar.server.db.migrations.SqlStatement;
 
-import javax.annotation.Nullable;
-
-import java.sql.SQLException;
-
 /**
  * See http://jira.codehaus.org/browse/SONAR-5758
  *
index 03ad53ab61ca6c2e3881a045c9e4fb13c744d119..be9751716502fd217376665e57840aeee0e0966d 100644 (file)
  */
 package org.sonar.server.db.migrations.v50;
 
+import static com.google.common.base.Charsets.UTF_8;
+
+import java.sql.SQLException;
+import java.util.Date;
+
+import javax.annotation.Nullable;
+
 import org.apache.commons.lang.StringUtils;
 import org.sonar.api.utils.System2;
 import org.sonar.core.persistence.Database;
@@ -28,13 +35,6 @@ import org.sonar.server.db.migrations.Select.Row;
 import org.sonar.server.db.migrations.Select.RowReader;
 import org.sonar.server.db.migrations.SqlStatement;
 
-import javax.annotation.Nullable;
-
-import java.sql.SQLException;
-import java.util.Date;
-
-import static com.google.common.base.Charsets.UTF_8;
-
 /**
  * Used in the Active Record Migration 714
  *
index 9b4dfca0e313a3e62e2eec03bca2d9786fd6c4c7..7bbfde25d5c47dc07e12552d20582764b5461cec 100644 (file)
@@ -19,6 +19,9 @@
  */
 package org.sonar.server.db.migrations.v50;
 
+import java.sql.SQLException;
+import java.util.Date;
+
 import org.sonar.api.utils.System2;
 import org.sonar.core.persistence.Database;
 import org.sonar.server.db.migrations.BaseDataChange;
@@ -26,9 +29,6 @@ import org.sonar.server.db.migrations.MassUpdate;
 import org.sonar.server.db.migrations.Select;
 import org.sonar.server.db.migrations.SqlStatement;
 
-import java.sql.SQLException;
-import java.util.Date;
-
 public class FeedIssueLongDates extends BaseDataChange {
 
   private final System2 system;
index 589c080501ef15dc5c4f8af427bf4e0999faebc9..f0a6e89393fa3a4aeba35a4ef606133f4c2eeb32 100644 (file)
 
 package org.sonar.server.db.migrations.v50;
 
+import java.sql.SQLException;
+
 import org.sonar.core.persistence.Database;
 import org.sonar.server.db.migrations.BaseDataChange;
 import org.sonar.server.db.migrations.MassUpdate;
 import org.sonar.server.db.migrations.Select;
 import org.sonar.server.db.migrations.SqlStatement;
 
-import java.sql.SQLException;
-
 /**
  * Used in the Active Record Migration 712
  *
index ea3aa3ca172f676bf4d1e4d7adc6e496ee6197ac..fc26516b454b58ae1625b13e9f1c288572a7b5bc 100644 (file)
  */
 package org.sonar.server.db.migrations.v50;
 
-import com.google.common.base.Splitter;
-import com.google.common.collect.ImmutableList;
+import static com.google.common.base.Charsets.UTF_8;
+
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStreamWriter;
+import java.io.StringReader;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+
 import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.commons.lang.StringUtils;
 import org.codehaus.stax2.XMLInputFactory2;
@@ -31,15 +43,8 @@ import org.sonar.api.measures.CoreMetrics;
 import org.sonar.api.utils.KeyValueFormat;
 import org.sonar.api.utils.text.CsvWriter;
 
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
-
-import java.io.ByteArrayOutputStream;
-import java.io.OutputStreamWriter;
-import java.io.StringReader;
-import java.util.*;
-
-import static com.google.common.base.Charsets.UTF_8;
+import com.google.common.base.Splitter;
+import com.google.common.collect.ImmutableList;
 
 class FileSourceDto {
 
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/InsertProjectsAuthorizationUpdatedAtMigration.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/InsertProjectsAuthorizationUpdatedAtMigration.java
deleted file mode 100644 (file)
index c4688c2..0000000
+++ /dev/null
@@ -1,65 +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.
- */
-
-package org.sonar.server.db.migrations.v50;
-
-import org.sonar.api.utils.System2;
-import org.sonar.core.persistence.Database;
-import org.sonar.server.db.migrations.BaseDataChange;
-import org.sonar.server.db.migrations.MassUpdate;
-import org.sonar.server.db.migrations.Select;
-import org.sonar.server.db.migrations.SqlStatement;
-
-import java.sql.SQLException;
-
-/**
- * Used in the Active Record Migration 716
- *
- * @since 5.0
- */
-public class InsertProjectsAuthorizationUpdatedAtMigration extends BaseDataChange {
-
-  private final System2 system;
-
-  public InsertProjectsAuthorizationUpdatedAtMigration(Database db, System2 system) {
-    super(db);
-    this.system = system;
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    final long now = system.now();
-
-    MassUpdate massUpdate = context.prepareMassUpdate();
-    massUpdate.select("SELECT p.id FROM projects p WHERE p.scope=? AND p.enabled=? and p.authorization_updated_at IS NULL").setString(1, "PRJ").setBoolean(2, true);
-    massUpdate.update("UPDATE projects SET authorization_updated_at=? WHERE id=?");
-    massUpdate.rowPluralName("projects");
-    massUpdate.execute(new MassUpdate.Handler() {
-      @Override
-      public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
-        Long id = row.getNullableLong(1);
-        update.setLong(1, now);
-        update.setLong(2, id);
-        return true;
-      }
-    });
-  }
-
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/InsertProjectsAuthorizationUpdatedAtMigrationStep.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/InsertProjectsAuthorizationUpdatedAtMigrationStep.java
new file mode 100644 (file)
index 0000000..ca4e108
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+
+package org.sonar.server.db.migrations.v50;
+
+import java.sql.SQLException;
+
+import org.sonar.api.utils.System2;
+import org.sonar.core.persistence.Database;
+import org.sonar.server.db.migrations.BaseDataChange;
+import org.sonar.server.db.migrations.MassUpdate;
+import org.sonar.server.db.migrations.Select;
+import org.sonar.server.db.migrations.SqlStatement;
+
+/**
+ * Used in the Active Record Migration 716
+ *
+ * @since 5.0
+ */
+public class InsertProjectsAuthorizationUpdatedAtMigrationStep extends BaseDataChange {
+
+  private final System2 system;
+
+  public InsertProjectsAuthorizationUpdatedAtMigrationStep(Database db, System2 system) {
+    super(db);
+    this.system = system;
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    final long now = system.now();
+
+    MassUpdate massUpdate = context.prepareMassUpdate();
+    massUpdate.select("SELECT p.id FROM projects p WHERE p.scope=? AND p.enabled=? and p.authorization_updated_at IS NULL").setString(1, "PRJ").setBoolean(2, true);
+    massUpdate.update("UPDATE projects SET authorization_updated_at=? WHERE id=?");
+    massUpdate.rowPluralName("projects");
+    massUpdate.execute(new MassUpdate.Handler() {
+      @Override
+      public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
+        Long id = row.getNullableLong(1);
+        update.setLong(1, now);
+        update.setLong(2, id);
+        return true;
+      }
+    });
+  }
+
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigration.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigration.java
deleted file mode 100644 (file)
index c1ce39f..0000000
+++ /dev/null
@@ -1,183 +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.
- */
-
-package org.sonar.server.db.migrations.v50;
-
-import com.google.common.base.Splitter;
-import com.google.common.base.Strings;
-import org.apache.ibatis.session.ResultContext;
-import org.apache.ibatis.session.ResultHandler;
-import org.sonar.api.resources.Scopes;
-import org.sonar.api.utils.internal.Uuids;
-import org.sonar.core.persistence.DbSession;
-import org.sonar.core.persistence.migration.v50.Component;
-import org.sonar.core.persistence.migration.v50.Migration50Mapper;
-import org.sonar.server.db.DbClient;
-import org.sonar.server.db.migrations.DatabaseMigration;
-import org.sonar.server.util.ProgressLogger;
-
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicLong;
-
-import static com.google.common.collect.Lists.newArrayList;
-import static com.google.common.collect.Maps.newHashMap;
-
-/**
- * Used in the Active Record Migration 705
- *
- * @since 5.0
- */
-public class PopulateProjectsUuidColumnsMigration implements DatabaseMigration {
-
-  private final DbClient db;
-  private final AtomicLong counter = new AtomicLong(0L);
-
-  public PopulateProjectsUuidColumnsMigration(DbClient db) {
-    this.db = db;
-  }
-
-  @Override
-  public void execute() {
-    ProgressLogger progress = ProgressLogger.create(getClass(), counter);
-    progress.start();
-
-    final DbSession readSession = db.openSession(false);
-    final DbSession writeSession = db.openSession(true);
-    try {
-      readSession.select("org.sonar.core.persistence.migration.v50.Migration50Mapper.selectRootProjects", new ResultHandler() {
-        @Override
-        public void handleResult(ResultContext context) {
-          Component project = (Component) context.getResultObject();
-          Map<Long, String> uuidByComponentId = newHashMap();
-          migrateEnabledComponents(readSession, writeSession, project, uuidByComponentId);
-          migrateDisabledComponents(readSession, writeSession, project, uuidByComponentId);
-        }
-      });
-      writeSession.commit(true);
-      readSession.commit(true);
-
-      migrateComponentsWithoutUuid(readSession, writeSession);
-      writeSession.commit(true);
-
-      // log the total number of process rows
-      progress.log();
-    } finally {
-      readSession.close();
-      writeSession.close();
-      progress.stop();
-    }
-  }
-
-  private void migrateEnabledComponents(DbSession readSession, DbSession writeSession, Component project, Map<Long, String> uuidByComponentId) {
-    Map<Long, Component> componentsBySnapshotId = newHashMap();
-
-    List<Component> components = readSession.getMapper(Migration50Mapper.class).selectComponentChildrenForProjects(project.getId());
-    components.add(project);
-    List<Component> componentsToMigrate = newArrayList();
-    for (Component component : components) {
-      componentsBySnapshotId.put(component.getSnapshotId(), component);
-
-      // Not migrate components already having an UUID
-      if (component.getUuid() == null) {
-        component.setUuid(getOrCreateUuid(component, uuidByComponentId));
-        component.setProjectUuid(getOrCreateUuid(project, uuidByComponentId));
-        component.setModuleUuidPath("");
-        componentsToMigrate.add(component);
-      }
-    }
-
-    for (Component component : componentsToMigrate) {
-      updateComponent(component, project, componentsBySnapshotId, uuidByComponentId);
-      writeSession.getMapper(Migration50Mapper.class).updateComponentUuids(component);
-      counter.getAndIncrement();
-    }
-  }
-
-  private void migrateDisabledComponents(DbSession readSession, DbSession writeSession, Component project, Map<Long, String> uuidByComponentId) {
-    String projectUuid = getOrCreateUuid(project, uuidByComponentId);
-    for (Component component : readSession.getMapper(Migration50Mapper.class).selectDisabledDirectComponentChildrenForProjects(project.getId())) {
-      component.setUuid(getOrCreateUuid(component, uuidByComponentId));
-      component.setProjectUuid(projectUuid);
-      component.setModuleUuidPath("");
-
-      writeSession.getMapper(Migration50Mapper.class).updateComponentUuids(component);
-      counter.getAndIncrement();
-    }
-    for (Component component : readSession.getMapper(Migration50Mapper.class).selectDisabledNoneDirectComponentChildrenForProjects(project.getId())) {
-      component.setUuid(getOrCreateUuid(component, uuidByComponentId));
-      component.setProjectUuid(projectUuid);
-      component.setModuleUuidPath("");
-
-      writeSession.getMapper(Migration50Mapper.class).updateComponentUuids(component);
-      counter.getAndIncrement();
-    }
-  }
-
-  private void updateComponent(Component component, Component project, Map<Long, Component> componentsBySnapshotId, Map<Long, String> uuidByComponentId) {
-    String snapshotPath = component.getSnapshotPath();
-    StringBuilder moduleUuidPath = new StringBuilder();
-    Component lastModule = null;
-    if (!Strings.isNullOrEmpty(snapshotPath)) {
-      for (String s : Splitter.on(".").omitEmptyStrings().split(snapshotPath)) {
-        Long snapshotId = Long.valueOf(s);
-        Component currentComponent = componentsBySnapshotId.get(snapshotId);
-        if (currentComponent.getScope().equals(Scopes.PROJECT)) {
-          lastModule = currentComponent;
-          moduleUuidPath.append(currentComponent.getUuid()).append(".");
-        }
-      }
-    }
-    if (moduleUuidPath.length() > 0) {
-      // Remove last '.'
-      moduleUuidPath.deleteCharAt(moduleUuidPath.length() - 1);
-      component.setModuleUuidPath(moduleUuidPath.toString());
-    }
-
-    // Module UUID contains direct module of a component
-    if (lastModule != null) {
-      component.setModuleUuid(getOrCreateUuid(lastModule, uuidByComponentId));
-    }
-  }
-
-  private void migrateComponentsWithoutUuid(DbSession readSession, DbSession writeSession) {
-    for (Component component : readSession.getMapper(Migration50Mapper.class).selectComponentsWithoutUuid()) {
-      String uuid = Uuids.create();
-      component.setUuid(uuid);
-      component.setProjectUuid(uuid);
-      component.setModuleUuidPath("");
-
-      writeSession.getMapper(Migration50Mapper.class).updateComponentUuids(component);
-      counter.getAndIncrement();
-    }
-  }
-
-  private static String getOrCreateUuid(Component component, Map<Long, String> uuidByComponentId) {
-    String existingUuid = component.getUuid();
-    String uuid = existingUuid == null ? uuidByComponentId.get(component.getId()) : existingUuid;
-    if (uuid == null) {
-      String newUuid = Uuids.create();
-      uuidByComponentId.put(component.getId(), newUuid);
-      return newUuid;
-    }
-    return uuid;
-  }
-
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationStep.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationStep.java
new file mode 100644 (file)
index 0000000..e6e51dc
--- /dev/null
@@ -0,0 +1,184 @@
+/*
+ * 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.
+ */
+
+package org.sonar.server.db.migrations.v50;
+
+import static com.google.common.collect.Lists.newArrayList;
+import static com.google.common.collect.Maps.newHashMap;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.apache.ibatis.session.ResultContext;
+import org.apache.ibatis.session.ResultHandler;
+import org.sonar.api.resources.Scopes;
+import org.sonar.api.utils.internal.Uuids;
+import org.sonar.core.persistence.DbSession;
+import org.sonar.core.persistence.migration.v50.Component;
+import org.sonar.core.persistence.migration.v50.Migration50Mapper;
+import org.sonar.server.db.DbClient;
+import org.sonar.server.db.migrations.MigrationStep;
+import org.sonar.server.util.ProgressLogger;
+
+import com.google.common.base.Splitter;
+import com.google.common.base.Strings;
+
+/**
+ * Used in the Active Record Migration 705
+ *
+ * @since 5.0
+ */
+public class PopulateProjectsUuidColumnsMigrationStep implements MigrationStep {
+
+  private final DbClient db;
+  private final AtomicLong counter = new AtomicLong(0L);
+
+  public PopulateProjectsUuidColumnsMigrationStep(DbClient db) {
+    this.db = db;
+  }
+
+  @Override
+  public void execute() {
+    ProgressLogger progress = ProgressLogger.create(getClass(), counter);
+    progress.start();
+
+    final DbSession readSession = db.openSession(false);
+    final DbSession writeSession = db.openSession(true);
+    try {
+      readSession.select("org.sonar.core.persistence.migration.v50.Migration50Mapper.selectRootProjects", new ResultHandler() {
+        @Override
+        public void handleResult(ResultContext context) {
+          Component project = (Component) context.getResultObject();
+          Map<Long, String> uuidByComponentId = newHashMap();
+          migrateEnabledComponents(readSession, writeSession, project, uuidByComponentId);
+          migrateDisabledComponents(readSession, writeSession, project, uuidByComponentId);
+        }
+      });
+      writeSession.commit(true);
+      readSession.commit(true);
+
+      migrateComponentsWithoutUuid(readSession, writeSession);
+      writeSession.commit(true);
+
+      // log the total number of process rows
+      progress.log();
+    } finally {
+      readSession.close();
+      writeSession.close();
+      progress.stop();
+    }
+  }
+
+  private void migrateEnabledComponents(DbSession readSession, DbSession writeSession, Component project, Map<Long, String> uuidByComponentId) {
+    Map<Long, Component> componentsBySnapshotId = newHashMap();
+
+    List<Component> components = readSession.getMapper(Migration50Mapper.class).selectComponentChildrenForProjects(project.getId());
+    components.add(project);
+    List<Component> componentsToMigrate = newArrayList();
+    for (Component component : components) {
+      componentsBySnapshotId.put(component.getSnapshotId(), component);
+
+      // Not migrate components already having an UUID
+      if (component.getUuid() == null) {
+        component.setUuid(getOrCreateUuid(component, uuidByComponentId));
+        component.setProjectUuid(getOrCreateUuid(project, uuidByComponentId));
+        component.setModuleUuidPath("");
+        componentsToMigrate.add(component);
+      }
+    }
+
+    for (Component component : componentsToMigrate) {
+      updateComponent(component, project, componentsBySnapshotId, uuidByComponentId);
+      writeSession.getMapper(Migration50Mapper.class).updateComponentUuids(component);
+      counter.getAndIncrement();
+    }
+  }
+
+  private void migrateDisabledComponents(DbSession readSession, DbSession writeSession, Component project, Map<Long, String> uuidByComponentId) {
+    String projectUuid = getOrCreateUuid(project, uuidByComponentId);
+    for (Component component : readSession.getMapper(Migration50Mapper.class).selectDisabledDirectComponentChildrenForProjects(project.getId())) {
+      component.setUuid(getOrCreateUuid(component, uuidByComponentId));
+      component.setProjectUuid(projectUuid);
+      component.setModuleUuidPath("");
+
+      writeSession.getMapper(Migration50Mapper.class).updateComponentUuids(component);
+      counter.getAndIncrement();
+    }
+    for (Component component : readSession.getMapper(Migration50Mapper.class).selectDisabledNoneDirectComponentChildrenForProjects(project.getId())) {
+      component.setUuid(getOrCreateUuid(component, uuidByComponentId));
+      component.setProjectUuid(projectUuid);
+      component.setModuleUuidPath("");
+
+      writeSession.getMapper(Migration50Mapper.class).updateComponentUuids(component);
+      counter.getAndIncrement();
+    }
+  }
+
+  private void updateComponent(Component component, Component project, Map<Long, Component> componentsBySnapshotId, Map<Long, String> uuidByComponentId) {
+    String snapshotPath = component.getSnapshotPath();
+    StringBuilder moduleUuidPath = new StringBuilder();
+    Component lastModule = null;
+    if (!Strings.isNullOrEmpty(snapshotPath)) {
+      for (String s : Splitter.on(".").omitEmptyStrings().split(snapshotPath)) {
+        Long snapshotId = Long.valueOf(s);
+        Component currentComponent = componentsBySnapshotId.get(snapshotId);
+        if (currentComponent.getScope().equals(Scopes.PROJECT)) {
+          lastModule = currentComponent;
+          moduleUuidPath.append(currentComponent.getUuid()).append(".");
+        }
+      }
+    }
+    if (moduleUuidPath.length() > 0) {
+      // Remove last '.'
+      moduleUuidPath.deleteCharAt(moduleUuidPath.length() - 1);
+      component.setModuleUuidPath(moduleUuidPath.toString());
+    }
+
+    // Module UUID contains direct module of a component
+    if (lastModule != null) {
+      component.setModuleUuid(getOrCreateUuid(lastModule, uuidByComponentId));
+    }
+  }
+
+  private void migrateComponentsWithoutUuid(DbSession readSession, DbSession writeSession) {
+    for (Component component : readSession.getMapper(Migration50Mapper.class).selectComponentsWithoutUuid()) {
+      String uuid = Uuids.create();
+      component.setUuid(uuid);
+      component.setProjectUuid(uuid);
+      component.setModuleUuidPath("");
+
+      writeSession.getMapper(Migration50Mapper.class).updateComponentUuids(component);
+      counter.getAndIncrement();
+    }
+  }
+
+  private static String getOrCreateUuid(Component component, Map<Long, String> uuidByComponentId) {
+    String existingUuid = component.getUuid();
+    String uuid = existingUuid == null ? uuidByComponentId.get(component.getId()) : existingUuid;
+    if (uuid == null) {
+      String newUuid = Uuids.create();
+      uuidByComponentId.put(component.getId(), newUuid);
+      return newUuid;
+    }
+    return uuid;
+  }
+
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/RemoveSortFieldFromIssueFiltersMigration.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/RemoveSortFieldFromIssueFiltersMigration.java
deleted file mode 100644 (file)
index 0f8c7f5..0000000
+++ /dev/null
@@ -1,89 +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.
- */
-package org.sonar.server.db.migrations.v50;
-
-import com.google.common.collect.Lists;
-import org.apache.commons.lang.StringUtils;
-import org.sonar.api.utils.System2;
-import org.sonar.core.persistence.Database;
-import org.sonar.server.db.migrations.BaseDataChange;
-import org.sonar.server.db.migrations.MassUpdate;
-import org.sonar.server.db.migrations.Select;
-import org.sonar.server.db.migrations.SqlStatement;
-
-import java.sql.SQLException;
-import java.util.Date;
-import java.util.List;
-
-// TODO could be refactored to benefit from existing code of ReplaceIssueFiltersProjectKeyByUuid
-// -> make any change of issue_filters easier
-public class RemoveSortFieldFromIssueFiltersMigration extends BaseDataChange {
-
-  private static final char FIELD_SEPARATOR = '|';
-  private static final String SORT_KEY = "sort=";
-  private static final String ASC_KEY = "asc=";
-
-  private final System2 system;
-
-  public RemoveSortFieldFromIssueFiltersMigration(Database db, System2 system) {
-    super(db);
-    this.system = system;
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    MassUpdate massUpdate = context.prepareMassUpdate();
-    massUpdate.select("select id,data from issue_filters where data like '%" + SORT_KEY + "%' or data like '%" + ASC_KEY +"%'");
-    massUpdate.update("update issue_filters set data=?, updated_at=? where id=?");
-    massUpdate.rowPluralName("issue filters");
-    massUpdate.execute(new FilterHandler(new Date(system.now())));
-  }
-
-  private static class FilterHandler implements MassUpdate.Handler {
-    private final Date now;
-
-    private FilterHandler(Date now) {
-      this.now = now;
-    }
-
-    @Override
-    public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
-      String data = row.getNullableString(2);
-      String[] fields = StringUtils.split(data, FIELD_SEPARATOR);
-
-      boolean found = false;
-      List<String> fieldsToKeep = Lists.newArrayList();
-      for (String field : fields) {
-        if (field.startsWith(SORT_KEY) || field.startsWith(ASC_KEY)) {
-          found = true;
-        } else {
-          fieldsToKeep.add(field);
-        }
-      }
-      if (found) {
-        // data without 'sort' field
-        update.setString(1, StringUtils.join(fieldsToKeep, FIELD_SEPARATOR));
-        update.setDate(2, now);
-        update.setLong(3, row.getNullableLong(1));
-      }
-      return found;
-    }
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/RemoveSortFieldFromIssueFiltersMigrationStep.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/RemoveSortFieldFromIssueFiltersMigrationStep.java
new file mode 100644 (file)
index 0000000..874d1cc
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * 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.
+ */
+package org.sonar.server.db.migrations.v50;
+
+import java.sql.SQLException;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.commons.lang.StringUtils;
+import org.sonar.api.utils.System2;
+import org.sonar.core.persistence.Database;
+import org.sonar.server.db.migrations.BaseDataChange;
+import org.sonar.server.db.migrations.MassUpdate;
+import org.sonar.server.db.migrations.Select;
+import org.sonar.server.db.migrations.SqlStatement;
+
+import com.google.common.collect.Lists;
+
+// TODO could be refactored to benefit from existing code of ReplaceIssueFiltersProjectKeyByUuid
+// -> make any change of issue_filters easier
+public class RemoveSortFieldFromIssueFiltersMigrationStep extends BaseDataChange {
+
+  private static final char FIELD_SEPARATOR = '|';
+  private static final String SORT_KEY = "sort=";
+  private static final String ASC_KEY = "asc=";
+
+  private final System2 system;
+
+  public RemoveSortFieldFromIssueFiltersMigrationStep(Database db, System2 system) {
+    super(db);
+    this.system = system;
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    MassUpdate massUpdate = context.prepareMassUpdate();
+    massUpdate.select("select id,data from issue_filters where data like '%" + SORT_KEY + "%' or data like '%" + ASC_KEY + "%'");
+    massUpdate.update("update issue_filters set data=?, updated_at=? where id=?");
+    massUpdate.rowPluralName("issue filters");
+    massUpdate.execute(new FilterHandler(new Date(system.now())));
+  }
+
+  private static class FilterHandler implements MassUpdate.Handler {
+    private final Date now;
+
+    private FilterHandler(Date now) {
+      this.now = now;
+    }
+
+    @Override
+    public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
+      String data = row.getNullableString(2);
+      String[] fields = StringUtils.split(data, FIELD_SEPARATOR);
+
+      boolean found = false;
+      List<String> fieldsToKeep = Lists.newArrayList();
+      for (String field : fields) {
+        if (field.startsWith(SORT_KEY) || field.startsWith(ASC_KEY)) {
+          found = true;
+        } else {
+          fieldsToKeep.add(field);
+        }
+      }
+      if (found) {
+        // data without 'sort' field
+        update.setString(1, StringUtils.join(fieldsToKeep, FIELD_SEPARATOR));
+        update.setDate(2, now);
+        update.setLong(3, row.getNullableLong(1));
+      }
+      return found;
+    }
+  }
+}
index 2632f3b27c757217e2eb0f459e49313dad9b8e0e..0beb52287df1dc004d4de61f4a4fb18eb8b4ecf6 100644 (file)
 
 package org.sonar.server.db.migrations.v50;
 
-import org.apache.commons.dbutils.DbUtils;
-import org.sonar.api.utils.System2;
-import org.sonar.core.persistence.Database;
-import org.sonar.server.db.migrations.*;
-
-import javax.annotation.Nullable;
-
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.util.Date;
 
+import javax.annotation.Nullable;
+
+import org.apache.commons.dbutils.DbUtils;
+import org.sonar.api.utils.System2;
+import org.sonar.core.persistence.Database;
+import org.sonar.server.db.migrations.BaseDataChange;
+import org.sonar.server.db.migrations.MassUpdate;
+import org.sonar.server.db.migrations.Select;
+import org.sonar.server.db.migrations.SqlStatement;
+import org.sonar.server.db.migrations.SqlUtil;
+
 /**
  * Used in the Active Record Migration 710
  *
@@ -84,7 +88,7 @@ public class ReplaceIssueFiltersProjectKeyByUuid extends BaseDataChange {
   private String convertData(PreparedStatement pstmt, String data) throws SQLException {
     StringBuilder newFields = new StringBuilder();
     String[] fields = data.split("\\|");
-    for (int i=0; i<fields.length; i++) {
+    for (int i = 0; i < fields.length; i++) {
       String field = fields[i];
       if (field.contains("componentRoots")) {
         String[] componentRootValues = field.split("=");
index 529c3436e375db74645ccaa51c8d5596c4afe38e..083c0d0f7567e9919da2095f7088c094d213ed81 100644 (file)
 
 package org.sonar.server.db.migrations.v51;
 
+import java.sql.SQLException;
+
 import org.sonar.core.persistence.Database;
 import org.sonar.server.db.migrations.AddColumnsBuilder;
 import org.sonar.server.db.migrations.DdlChange;
 
-import java.sql.SQLException;
-
 /**
  * Add the following columns to the issues table :
  * - issue_creation_date_ms
index ffc4a1103c0452552f03894e428e01332ea15b0a..0602f7f025bd14921ce2e60ecaaa9a9dae50fb92 100644 (file)
  */
 package org.sonar.server.db.migrations.v51;
 
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
+import java.sql.SQLException;
+import java.util.Date;
+import java.util.List;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.sonar.api.utils.MessageException;
@@ -29,12 +34,8 @@ import org.sonar.core.persistence.Database;
 import org.sonar.server.db.migrations.BaseDataChange;
 import org.sonar.server.db.migrations.Select;
 
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-import java.sql.SQLException;
-import java.util.Date;
-import java.util.List;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
 
 /**
  * See http://jira.codehaus.org/browse/SONAR-6187
index 86a1ce33a1fc640563d4891869845e2627b689a6..ce46495c419c7fd022a3d12b100953c9ce0d0e7b 100644 (file)
 
 package org.sonar.server.db.migrations.v51;
 
-import com.google.common.base.Joiner;
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.Multimap;
+import static com.google.common.collect.Lists.newArrayList;
+
+import java.sql.SQLException;
+import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
+
+import javax.annotation.CheckForNull;
+
 import org.sonar.api.utils.System2;
 import org.sonar.core.persistence.Database;
 import org.sonar.server.db.migrations.BaseDataChange;
@@ -31,14 +37,9 @@ import org.sonar.server.db.migrations.Upsert;
 import org.sonar.server.db.migrations.UpsertImpl;
 import org.sonar.server.util.ProgressLogger;
 
-import javax.annotation.CheckForNull;
-
-import java.sql.SQLException;
-import java.util.Collection;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicLong;
-
-import static com.google.common.collect.Lists.newArrayList;
+import com.google.common.base.Joiner;
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Multimap;
 
 public class CopyScmAccountsFromAuthorsToUsers extends BaseDataChange {
 
index 3b04ac3dbe19f76410a0e8f7df8a24f2df7e5471..08296e63c5df10feb19e506ecd3dc07ba324efae 100644 (file)
 
 package org.sonar.server.db.migrations.v51;
 
-import com.google.common.annotations.VisibleForTesting;
+import java.sql.SQLException;
+
 import org.sonar.core.persistence.Database;
 import org.sonar.server.db.migrations.DdlChange;
 import org.sonar.server.db.migrations.DropColumnsBuilder;
 
-import java.sql.SQLException;
+import com.google.common.annotations.VisibleForTesting;
 
 /**
  * Drop the following columns from the issues table :
index a0c981df11043319e4a5dbd69e87b615f566566e..5bebc27244853d27cd41a817defbfabe9501703d 100644 (file)
@@ -20,6 +20,9 @@
 
 package org.sonar.server.db.migrations.v51;
 
+import java.sql.SQLException;
+import java.util.Date;
+
 import org.sonar.api.utils.System2;
 import org.sonar.core.persistence.Database;
 import org.sonar.server.db.migrations.BaseDataChange;
@@ -27,9 +30,6 @@ import org.sonar.server.db.migrations.MassUpdate;
 import org.sonar.server.db.migrations.Select;
 import org.sonar.server.db.migrations.SqlStatement;
 
-import java.sql.SQLException;
-import java.util.Date;
-
 public class FeedAnalysisReportsLongDates extends BaseDataChange {
 
   private final System2 system;
index f7a5ef9332ac8d5b7bdf38928903e5e21ec5a7c8..afb9e237fa0eed62d231f1d66e99ceb3f5ee6a56 100644 (file)
@@ -20,6 +20,9 @@
 
 package org.sonar.server.db.migrations.v51;
 
+import java.sql.SQLException;
+import java.util.Date;
+
 import org.sonar.api.utils.System2;
 import org.sonar.core.persistence.Database;
 import org.sonar.server.db.migrations.BaseDataChange;
@@ -27,9 +30,6 @@ import org.sonar.server.db.migrations.MassUpdate;
 import org.sonar.server.db.migrations.Select;
 import org.sonar.server.db.migrations.SqlStatement;
 
-import java.sql.SQLException;
-import java.util.Date;
-
 public class FeedEventsLongDates extends BaseDataChange {
 
   private final System2 system2;
index 6ea6cd4159f1f9a3148e2620f486f7a37125bdfe..381b7c67d84d9cd04adcceefd499767e68cef577 100644 (file)
  */
 package org.sonar.server.db.migrations.v51;
 
-import com.google.common.base.Function;
-import com.google.common.base.Splitter;
-import com.google.common.collect.Iterables;
+import java.sql.SQLException;
+import java.util.Iterator;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
 import org.apache.commons.csv.CSVFormat;
 import org.apache.commons.csv.CSVParser;
 import org.apache.commons.csv.CSVRecord;
@@ -36,11 +39,9 @@ import org.sonar.server.db.migrations.Select;
 import org.sonar.server.db.migrations.SqlStatement;
 import org.sonar.server.source.db.FileSourceDb;
 
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import java.sql.SQLException;
-import java.util.Iterator;
+import com.google.common.base.Function;
+import com.google.common.base.Splitter;
+import com.google.common.collect.Iterables;
 
 public class FeedFileSourcesBinaryData extends BaseDataChange {
 
index d522dae4ade12b10350a850e0fd2df36cf522496..dda923f6246ce8f1677cb2b8c7b753ca30d8efa9 100644 (file)
@@ -20,6 +20,9 @@
 
 package org.sonar.server.db.migrations.v51;
 
+import java.sql.SQLException;
+import java.util.Date;
+
 import org.sonar.api.utils.System2;
 import org.sonar.core.persistence.Database;
 import org.sonar.server.db.migrations.BaseDataChange;
@@ -27,9 +30,6 @@ import org.sonar.server.db.migrations.MassUpdate;
 import org.sonar.server.db.migrations.Select;
 import org.sonar.server.db.migrations.SqlStatement;
 
-import java.sql.SQLException;
-import java.util.Date;
-
 public class FeedIssueChangesLongDates extends BaseDataChange {
 
   private final System2 system;
index 7c26de3a13a05b05e31347e9781b2eb99b42b16a..4cc84f02d59fd8537f863084e05d0545ffc0d736 100644 (file)
@@ -20,6 +20,8 @@
 
 package org.sonar.server.db.migrations.v51;
 
+import java.sql.SQLException;
+
 import org.sonar.core.persistence.Database;
 import org.sonar.server.db.migrations.BaseDataChange;
 import org.sonar.server.db.migrations.MassUpdate;
@@ -27,8 +29,6 @@ import org.sonar.server.db.migrations.MassUpdate.Handler;
 import org.sonar.server.db.migrations.Select.Row;
 import org.sonar.server.db.migrations.SqlStatement;
 
-import java.sql.SQLException;
-
 public class FeedIssueComponentUuids extends BaseDataChange {
 
   public FeedIssueComponentUuids(Database db) {
index 5eaf90f8f487a45cfd8cfb933e91740cd35f0d23..fc5ec5e44dba5fef4293fe3f38187639d5b75036 100644 (file)
@@ -19,8 +19,9 @@
  */
 package org.sonar.server.db.migrations.v51;
 
-import com.google.common.base.Joiner;
-import com.google.common.collect.Maps;
+import java.sql.SQLException;
+import java.util.Map;
+
 import org.apache.commons.lang.StringUtils;
 import org.sonar.api.utils.System2;
 import org.sonar.core.persistence.Database;
@@ -31,9 +32,8 @@ import org.sonar.server.db.migrations.Select.Row;
 import org.sonar.server.db.migrations.Select.RowHandler;
 import org.sonar.server.db.migrations.SqlStatement;
 
-import java.sql.SQLException;
-import java.util.Map;
-
+import com.google.common.base.Joiner;
+import com.google.common.collect.Maps;
 
 /**
  * SONAR-5897
index 6573c1f6baafbabaa6c0277712b9e9c5df21c932..26721ee78a50a3ba85e489e1d1cd58cb5b70d562 100644 (file)
@@ -20,6 +20,9 @@
 
 package org.sonar.server.db.migrations.v51;
 
+import java.sql.SQLException;
+import java.util.Date;
+
 import org.sonar.api.utils.System2;
 import org.sonar.core.persistence.Database;
 import org.sonar.server.db.migrations.BaseDataChange;
@@ -27,9 +30,6 @@ import org.sonar.server.db.migrations.MassUpdate;
 import org.sonar.server.db.migrations.Select;
 import org.sonar.server.db.migrations.SqlStatement;
 
-import java.sql.SQLException;
-import java.util.Date;
-
 public class FeedIssuesLongDates extends BaseDataChange {
 
   private final System2 system2;
index d127b7f8f71f5b9369a243df109c69067388e804..4cf0d75c6b7bf4c9524cbebd98dd5e55de456c41 100644 (file)
@@ -20,6 +20,9 @@
 
 package org.sonar.server.db.migrations.v51;
 
+import java.sql.SQLException;
+import java.util.Date;
+
 import org.sonar.api.utils.System2;
 import org.sonar.core.persistence.Database;
 import org.sonar.server.db.migrations.BaseDataChange;
@@ -27,9 +30,6 @@ import org.sonar.server.db.migrations.MassUpdate;
 import org.sonar.server.db.migrations.Select;
 import org.sonar.server.db.migrations.SqlStatement;
 
-import java.sql.SQLException;
-import java.util.Date;
-
 public class FeedManualMeasuresLongDates extends BaseDataChange {
 
   private final System2 system2;
index bf4ddd0841910772ea90684a5283e4e0198fc142..85da73d60d31452ef018d63ffe0b468b1a44343d 100644 (file)
@@ -20,6 +20,9 @@
 
 package org.sonar.server.db.migrations.v51;
 
+import java.sql.SQLException;
+import java.util.Date;
+
 import org.sonar.api.utils.System2;
 import org.sonar.core.persistence.Database;
 import org.sonar.server.db.migrations.BaseDataChange;
@@ -27,9 +30,6 @@ import org.sonar.server.db.migrations.MassUpdate;
 import org.sonar.server.db.migrations.Select;
 import org.sonar.server.db.migrations.SqlStatement;
 
-import java.sql.SQLException;
-import java.util.Date;
-
 public class FeedSemaphoresLongDates extends BaseDataChange {
 
   private final System2 system2;
index dc2f6de26dfea3b83608af7c714f3bc715b2a6a4..71104ba29241e3c067324f5f7c79032039fc6663 100644 (file)
@@ -20,6 +20,9 @@
 
 package org.sonar.server.db.migrations.v51;
 
+import java.sql.SQLException;
+import java.util.Date;
+
 import org.sonar.api.utils.System2;
 import org.sonar.core.persistence.Database;
 import org.sonar.server.db.migrations.BaseDataChange;
@@ -27,9 +30,6 @@ import org.sonar.server.db.migrations.MassUpdate;
 import org.sonar.server.db.migrations.Select;
 import org.sonar.server.db.migrations.SqlStatement;
 
-import java.sql.SQLException;
-import java.util.Date;
-
 public class FeedSnapshotsLongDates extends BaseDataChange {
 
   private final System2 system2;
index 3907ddf94b1d5263c75f11fed8f269a4a0117ddc..7b85f4d65f6312f8b052483b8156a86e2131f3d8 100644 (file)
@@ -19,6 +19,9 @@
  */
 package org.sonar.server.db.migrations.v51;
 
+import java.sql.SQLException;
+import java.util.Date;
+
 import org.sonar.api.utils.System2;
 import org.sonar.core.persistence.Database;
 import org.sonar.server.db.migrations.BaseDataChange;
@@ -26,9 +29,6 @@ import org.sonar.server.db.migrations.MassUpdate;
 import org.sonar.server.db.migrations.Select;
 import org.sonar.server.db.migrations.SqlStatement;
 
-import java.sql.SQLException;
-import java.util.Date;
-
 public class FeedUsersLongDates extends BaseDataChange {
 
   private final System2 system;
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v51/RemovePermissionsOnModulesMigration.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v51/RemovePermissionsOnModulesMigration.java
deleted file mode 100644 (file)
index 2def644..0000000
+++ /dev/null
@@ -1,68 +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.
- */
-
-package org.sonar.server.db.migrations.v51;
-
-import org.sonar.core.persistence.Database;
-import org.sonar.server.db.migrations.BaseDataChange;
-import org.sonar.server.db.migrations.MassUpdate;
-import org.sonar.server.db.migrations.Select;
-import org.sonar.server.db.migrations.SqlStatement;
-
-import java.sql.SQLException;
-
-/**
- * See http://jira.codehaus.org/browse/SONAR-5596
- *
- * It's no possible to set permission on a module or a sub-view, but the batch was setting default permission on it on their creation.
- * As now it's no more the case, we need to purge this useless data.
- *
- * @since 5.1
- */
-public class RemovePermissionsOnModulesMigration extends BaseDataChange {
-
-  public RemovePermissionsOnModulesMigration(Database db) {
-    super(db);
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    removeUserRolePermissions(context, "user_roles", "user roles");
-    removeUserRolePermissions(context, "group_roles", "group roles");
-  }
-
-  private void removeUserRolePermissions(Context context, String tableName, String pluralName) throws SQLException {
-    MassUpdate massUpdate = context.prepareMassUpdate();
-    massUpdate.select("SELECT r.id " +
-      "FROM " + tableName + " r " +
-      "  INNER JOIN projects ON projects.id = r.resource_id " +
-      "WHERE projects.module_uuid IS NOT NULL");
-    massUpdate.update("DELETE FROM " + tableName + " WHERE id=?");
-    massUpdate.rowPluralName(pluralName);
-    massUpdate.execute(new MassUpdate.Handler() {
-      @Override
-      public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
-        update.setLong(1, row.getLong(1));
-        return true;
-      }
-    });
-  }
-
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v51/RemovePermissionsOnModulesMigrationStep.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v51/RemovePermissionsOnModulesMigrationStep.java
new file mode 100644 (file)
index 0000000..1261393
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * 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.
+ */
+
+package org.sonar.server.db.migrations.v51;
+
+import java.sql.SQLException;
+
+import org.sonar.core.persistence.Database;
+import org.sonar.server.db.migrations.BaseDataChange;
+import org.sonar.server.db.migrations.MassUpdate;
+import org.sonar.server.db.migrations.Select;
+import org.sonar.server.db.migrations.SqlStatement;
+
+/**
+ * See http://jira.codehaus.org/browse/SONAR-5596
+ *
+ * It's no possible to set permission on a module or a sub-view, but the batch was setting default permission on it on their creation.
+ * As now it's no more the case, we need to purge this useless data.
+ *
+ * @since 5.1
+ */
+public class RemovePermissionsOnModulesMigrationStep extends BaseDataChange {
+
+  public RemovePermissionsOnModulesMigrationStep(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    removeUserRolePermissions(context, "user_roles", "user roles");
+    removeUserRolePermissions(context, "group_roles", "group roles");
+  }
+
+  private void removeUserRolePermissions(Context context, String tableName, String pluralName) throws SQLException {
+    MassUpdate massUpdate = context.prepareMassUpdate();
+    massUpdate.select("SELECT r.id " +
+      "FROM " + tableName + " r " +
+      "  INNER JOIN projects ON projects.id = r.resource_id " +
+      "WHERE projects.module_uuid IS NOT NULL");
+    massUpdate.update("DELETE FROM " + tableName + " WHERE id=?");
+    massUpdate.rowPluralName(pluralName);
+    massUpdate.execute(new MassUpdate.Handler() {
+      @Override
+      public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
+        update.setLong(1, row.getLong(1));
+        return true;
+      }
+    });
+  }
+
+}
index e7862b474c61b208c4c72b2f185022e08ae98f74..3afe97015254233781af57cf64578d9b8e91df57 100644 (file)
  */
 package org.sonar.server.db.migrations.v51;
 
-import com.google.common.collect.Lists;
+import java.sql.SQLException;
+import java.util.Date;
+import java.util.List;
+
 import org.apache.commons.lang.StringUtils;
 import org.sonar.api.utils.System2;
 import org.sonar.core.persistence.Database;
@@ -28,9 +31,7 @@ import org.sonar.server.db.migrations.MassUpdate;
 import org.sonar.server.db.migrations.Select;
 import org.sonar.server.db.migrations.SqlStatement;
 
-import java.sql.SQLException;
-import java.util.Date;
-import java.util.List;
+import com.google.common.collect.Lists;
 
 public class RenameComponentRelatedParamsInIssueFilters extends BaseDataChange {
 
index 751926fb06b59d29b8fb1bdb38b46d8b871fe24b..e00604c500fa5ed917b749935dff15b24ef86463 100644 (file)
 
 package org.sonar.server.db.migrations.v51;
 
+import java.sql.SQLException;
+
+import javax.annotation.Nullable;
+
 import org.apache.commons.lang.StringUtils;
 import org.sonar.core.persistence.Database;
 import org.sonar.server.db.migrations.BaseDataChange;
@@ -28,10 +32,6 @@ import org.sonar.server.db.migrations.MassUpdate.Handler;
 import org.sonar.server.db.migrations.Select.Row;
 import org.sonar.server.db.migrations.SqlStatement;
 
-import javax.annotation.Nullable;
-
-import java.sql.SQLException;
-
 /**
  * SONAR-6054
  * SONAR-6119
index 5e2c83ddd5671169faae0721188d58a6394050db..8d7bba428f15e5c06a0dbe58f69375c244c7ddb5 100644 (file)
 
 package org.sonar.server.db.migrations.v52;
 
+import java.sql.SQLException;
+
 import org.sonar.core.persistence.Database;
 import org.sonar.server.db.migrations.BaseDataChange;
 import org.sonar.server.db.migrations.MassUpdate;
 import org.sonar.server.db.migrations.Select;
 import org.sonar.server.db.migrations.SqlStatement;
 
-import java.sql.SQLException;
-
 public class FeedEventsComponentUuid extends BaseDataChange {
 
   public FeedEventsComponentUuid(Database db) {
index a567bad67519fa66cae37dade00196976822fb82..1f8c8170dddf9477c4706e5cad8141d292b42345 100644 (file)
@@ -20,6 +20,8 @@
 
 package org.sonar.server.db.migrations.v52;
 
+import java.sql.SQLException;
+
 import org.sonar.core.persistence.Database;
 import org.sonar.server.db.migrations.BaseDataChange;
 import org.sonar.server.db.migrations.MassUpdate;
@@ -27,8 +29,6 @@ import org.sonar.server.db.migrations.MassUpdate.Handler;
 import org.sonar.server.db.migrations.Select.Row;
 import org.sonar.server.db.migrations.SqlStatement;
 
-import java.sql.SQLException;
-
 public class FeedProjectLinksComponentUuid extends BaseDataChange {
 
   public FeedProjectLinksComponentUuid(Database db) {
index 8fa506e48e739413850558a9b95623a31cecf34d..53c38deacf1205f0511d125937d25f46658de3fe 100644 (file)
  */
 package org.sonar.server.db.migrations.v52;
 
-import com.google.common.collect.HashBasedTable;
-import com.google.common.collect.Table;
+import java.sql.SQLException;
+
 import org.sonar.api.utils.log.Logger;
 import org.sonar.api.utils.log.Loggers;
 import org.sonar.core.persistence.Database;
-import org.sonar.server.db.migrations.*;
+import org.sonar.server.db.migrations.BaseDataChange;
+import org.sonar.server.db.migrations.MassUpdate;
 import org.sonar.server.db.migrations.MassUpdate.Handler;
+import org.sonar.server.db.migrations.Select;
 import org.sonar.server.db.migrations.Select.Row;
 import org.sonar.server.db.migrations.Select.RowReader;
+import org.sonar.server.db.migrations.SqlStatement;
+import org.sonar.server.db.migrations.Upsert;
 
-import java.sql.SQLException;
+import com.google.common.collect.HashBasedTable;
+import com.google.common.collect.Table;
 
 /**
  * SonarQube 5.2
@@ -56,7 +61,7 @@ public class MoveProjectProfileAssociation extends BaseDataChange {
       String profileName = row.getString(3);
       Long projectId = row.getNullableLong(4);
       String projectUuid = row.getString(5);
+
       if (profileKeysByLanguageThenName.contains(profileLanguage, profileName)) {
         String profileKey = profileKeysByLanguageThenName.get(profileLanguage, profileName);
 
index 4b284ba4ba62b96b42498caa62f2551468d0409f..1209df754c440b13d32cbc4c93cbe0b55e0ed7a9 100644 (file)
@@ -103,7 +103,7 @@ import org.sonar.server.dashboard.ws.DashboardsWebService;
 import org.sonar.server.db.DatabaseChecker;
 import org.sonar.server.db.DbClient;
 import org.sonar.server.db.EmbeddedDatabaseFactory;
-import org.sonar.server.db.migrations.DatabaseMigrations;
+import org.sonar.server.db.migrations.MigrationSteps;
 import org.sonar.server.db.migrations.DatabaseMigrator;
 import org.sonar.server.debt.*;
 import org.sonar.server.design.FileDesignWidget;
@@ -303,7 +303,7 @@ class ServerComponents {
       FileSourceDao.class
       ));
     components.addAll(CorePropertyDefinitions.all());
-    components.addAll(DatabaseMigrations.CLASSES);
+    components.addAll(MigrationSteps.CLASSES);
     components.addAll(DaoUtils.getDaoClasses());
     return components;
   }
diff --git a/server/sonar-server/src/test/java/org/sonar/server/db/migrations/DatabaseMigrationsTest.java b/server/sonar-server/src/test/java/org/sonar/server/db/migrations/DatabaseMigrationsTest.java
deleted file mode 100644 (file)
index 1386ae5..0000000
+++ /dev/null
@@ -1,33 +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.
- */
-
-package org.sonar.server.db.migrations;
-
-import org.junit.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class DatabaseMigrationsTest {
-
-  @Test
-  public void check_number_of_migrations() throws Exception {
-    assertThat(DatabaseMigrations.CLASSES).isNotEmpty();
-  }
-}
index c2ce5a734b8c6bc99649b7027f4e328d3f57e213..20ca936aefc41836edd7d08c615ef701c419ccdc 100644 (file)
@@ -47,7 +47,7 @@ public class DatabaseMigratorTest extends AbstractDaoTestCase {
   public ExpectedException thrown = ExpectedException.none();
 
   DbClient dbClient = mock(DbClient.class, Mockito.RETURNS_DEEP_STUBS);
-  DatabaseMigration[] migrations = new DatabaseMigration[]{new FakeMigration()};
+  MigrationStep[] migrations = new MigrationStep[]{new FakeMigrationStep()};
   ServerUpgradeStatus serverUpgradeStatus = mock(ServerUpgradeStatus.class);
   DatabaseMigrator migrator;
 
@@ -74,9 +74,9 @@ public class DatabaseMigratorTest extends AbstractDaoTestCase {
 
   @Test
   public void execute_migration() throws Exception {
-    assertThat(FakeMigration.executed).isFalse();
-    migrator.executeMigration(FakeMigration.class.getName());
-    assertThat(FakeMigration.executed).isTrue();
+    assertThat(FakeMigrationStep.executed).isFalse();
+    migrator.executeMigration(FakeMigrationStep.class.getName());
+    assertThat(FakeMigrationStep.executed).isTrue();
   }
 
   @Test
@@ -98,7 +98,7 @@ public class DatabaseMigratorTest extends AbstractDaoTestCase {
     assertThat(databaseMigrator.createDatabase()).isTrue();
   }
 
-  public static class FakeMigration implements DatabaseMigration {
+  public static class FakeMigrationStep implements MigrationStep {
     static boolean executed = false;
 
     @Override
diff --git a/server/sonar-server/src/test/java/org/sonar/server/db/migrations/MigrationStepsTest.java b/server/sonar-server/src/test/java/org/sonar/server/db/migrations/MigrationStepsTest.java
new file mode 100644 (file)
index 0000000..ca1955c
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+package org.sonar.server.db.migrations;
+
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class MigrationStepsTest {
+
+  @Test
+  public void check_number_of_migrations() throws Exception {
+    assertThat(MigrationSteps.CLASSES).isNotEmpty();
+  }
+}
index ef8117c362059073ffb00097d608fd91efe0f6b3..debda9a7f17ef51b5d68e6f2638a2d8098522f1c 100644 (file)
@@ -35,7 +35,7 @@ public class ViolationMigrationTest {
   public void migrate_violations() throws Exception {
     db.prepareDbUnit(getClass(), "migrate_violations.xml");
 
-    new ViolationMigration(db.database(), new Settings()).execute();
+    new ViolationMigrationStep(db.database(), new Settings()).execute();
 
     db.assertDbUnit(getClass(), "migrate_violations_result.xml", "issues", "issue_changes");
     assertMigrationEnded();
@@ -45,7 +45,7 @@ public class ViolationMigrationTest {
   public void no_violations_to_migrate() throws Exception {
     db.prepareDbUnit(getClass(), "no_violations_to_migrate.xml");
 
-    new ViolationMigration(db.database(), new Settings()).execute();
+    new ViolationMigrationStep(db.database(), new Settings()).execute();
 
     db.assertDbUnit(getClass(), "no_violations_to_migrate_result.xml", "issues", "issue_changes");
     assertMigrationEnded();
index 99c5320b39c2e411cb6bbb516483bee41f0c1c81..9250a571042b2db6219ebfba4ef58143f64941c4 100644 (file)
@@ -22,14 +22,14 @@ package org.sonar.server.db.migrations.v42;
 import org.junit.ClassRule;
 import org.junit.Test;
 import org.sonar.core.persistence.DbTester;
-import org.sonar.server.db.migrations.DatabaseMigration;
+import org.sonar.server.db.migrations.MigrationStep;
 
 public class CompleteIssueMessageMigrationTest {
 
   @ClassRule
   public static DbTester db = new DbTester().schema(CompleteIssueMessageMigrationTest.class, "schema.sql");
 
-  DatabaseMigration migration = new CompleteIssueMessageMigration(db.database());
+  MigrationStep migration = new CompleteIssueMessageMigrationStep(db.database());
 
   @Test
   public void execute() throws Exception {
index a2785eefc535e9920301a4294ef39dca54a7d400..c292eefd17818b65f280d13e000daeb43e70257c 100644 (file)
@@ -22,14 +22,14 @@ package org.sonar.server.db.migrations.v42;
 import org.junit.ClassRule;
 import org.junit.Test;
 import org.sonar.core.persistence.DbTester;
-import org.sonar.server.db.migrations.DatabaseMigration;
+import org.sonar.server.db.migrations.MigrationStep;
 
 public class PackageKeysMigrationTest {
 
   @ClassRule
   public static DbTester db = new DbTester().schema(PackageKeysMigrationTest.class, "schema.sql");
 
-  DatabaseMigration migration = new PackageKeysMigration(db.database());
+  MigrationStep migration = new PackageKeysMigrationStep(db.database());
 
   @Test
   public void execute() throws Exception {
index 5c3affa89a1cd5ed64b5c57848597a0a489c4fe8..2e755192bb4ccc10aa45584f5a1e512116851ceb 100644 (file)
@@ -50,14 +50,14 @@ public class ConvertIssueDebtToMinutesMigrationTest {
   @Mock
   PropertiesDao propertiesDao;
 
-  ConvertIssueDebtToMinutesMigration migration;
+  ConvertIssueDebtToMinutesMigrationStep migration;
 
   @Before
   public void setUp() throws Exception {
     when(system2.now()).thenReturn(DateUtils.parseDateTime("2014-02-19T19:10:03+0100").getTime());
     when(propertiesDao.selectGlobalProperty(WorkDurationConvertor.HOURS_IN_DAY_PROPERTY)).thenReturn(new PropertyDto().setValue("8"));
 
-    migration = new ConvertIssueDebtToMinutesMigration(db.database(), propertiesDao, system2);
+    migration = new ConvertIssueDebtToMinutesMigrationStep(db.database(), propertiesDao, system2);
   }
 
   @Test
index 33c3c8957f5b7649023142e2f976e1394a5ccca0..d96c8e8639094b3bd195f0517cd2aa8d54ba7870 100644 (file)
@@ -41,13 +41,13 @@ public class DevelopmentCostMeasuresMigrationTest {
   @Mock
   PropertiesDao propertiesDao;
 
-  DevelopmentCostMeasuresMigration migration;
+  DevelopmentCostMeasuresMigrationStep migration;
 
   @Before
   public void setUp() throws Exception {
     when(propertiesDao.selectGlobalProperty(WorkDurationConvertor.HOURS_IN_DAY_PROPERTY)).thenReturn(new PropertyDto().setValue("8"));
 
-    migration = new DevelopmentCostMeasuresMigration(db.database(), propertiesDao);
+    migration = new DevelopmentCostMeasuresMigrationStep(db.database(), propertiesDao);
   }
 
   @Test
index 4e78d9298f81b63191665deab6051bc8c25098db..18f2106ca6bf7f7a9c9caebdde1b84057cc992f0 100644 (file)
@@ -47,7 +47,7 @@ public class IssueChangelogMigrationTest {
   @Mock
   PropertiesDao propertiesDao;
 
-  IssueChangelogMigration migration;
+  IssueChangelogMigrationStep migration;
 
   @Before
   public void setUp() throws Exception {
@@ -56,7 +56,7 @@ public class IssueChangelogMigrationTest {
 
     WorkDurationConvertor convertor = new WorkDurationConvertor(propertiesDao);
     convertor.init();
-    migration = new IssueChangelogMigration(db.database(), system2, convertor);
+    migration = new IssueChangelogMigrationStep(db.database(), system2, convertor);
   }
 
   @Test
index 144542101b17f4b3a81fe266315d126994669523..9f126ab99917b2d6e1c3e34e8ad3d2a40a73e8b9 100644 (file)
@@ -41,13 +41,13 @@ public class NotResolvedIssuesOnRemovedComponentsMigrationTest {
   @Mock
   System2 system2;
 
-  NotResolvedIssuesOnRemovedComponentsMigration migration;
+  NotResolvedIssuesOnRemovedComponentsMigrationStep migration;
 
   @Before
   public void setUp() throws Exception {
     when(system2.now()).thenReturn(DateUtils.parseDate("2014-04-09").getTime());
 
-    migration = new NotResolvedIssuesOnRemovedComponentsMigration(db.database(), system2);
+    migration = new NotResolvedIssuesOnRemovedComponentsMigrationStep(db.database(), system2);
   }
 
   @Test
index 5b4452840072a926272ed4c61544bf359544bd7b..be7c894a7620b4cf35b5d5a3b0b09210df36336c 100644 (file)
@@ -30,11 +30,11 @@ public class RequirementMeasuresMigrationTest {
   @ClassRule
   public static DbTester db = new DbTester().schema(RequirementMeasuresMigrationTest.class, "schema.sql");
 
-  RequirementMeasuresMigration migration;
+  RequirementMeasuresMigrationStep migration;
 
   @Before
   public void setUp() throws Exception {
-    migration = new RequirementMeasuresMigration(db.database());
+    migration = new RequirementMeasuresMigrationStep(db.database());
   }
 
   @Test
index f290cc2abe088fa42819dbc215bcc7d3309a00f8..9b64cb67a451cca4a4291152e0d4892ffbd9daa8 100644 (file)
@@ -41,13 +41,13 @@ public class TechnicalDebtMeasuresMigrationTest {
   @Mock
   PropertiesDao propertiesDao;
 
-  TechnicalDebtMeasuresMigration migration;
+  TechnicalDebtMeasuresMigrationStep migration;
 
   @Before
   public void setUp() throws Exception {
     when(propertiesDao.selectGlobalProperty(WorkDurationConvertor.HOURS_IN_DAY_PROPERTY)).thenReturn(new PropertyDto().setValue("8"));
 
-    migration = new TechnicalDebtMeasuresMigration(db.database(), propertiesDao);
+    migration = new TechnicalDebtMeasuresMigrationStep(db.database(), propertiesDao);
   }
 
   @Test
index ceb22da3b6aa408f65731ff7f941b5a20e992476..94971c2b84dc845b5d20987ef122a05235c21e95 100644 (file)
@@ -42,7 +42,7 @@ public class ChangeLogMigrationTest {
   System2 system2 = mock(System2.class);
   DbClient dbClient;
   ActivityDao dao;
-  ChangeLogMigration migration;
+  ChangeLogMigrationStep migration;
   DbSession session;
 
   @Before
@@ -50,7 +50,7 @@ public class ChangeLogMigrationTest {
     when(system2.now()).thenReturn(DateUtils.parseDate("2014-03-13").getTime());
     dao = new ActivityDao(db.myBatis(), system2);
     dbClient = new DbClient(db.database(), db.myBatis(), dao);
-    migration = new ChangeLogMigration(dao, dbClient);
+    migration = new ChangeLogMigrationStep(dao, dbClient);
     session = dbClient.openSession(false);
   }
 
index e7325c14cb7f41e49d79c1cf3a816ffdbe80238c..0510b0f191076806071b74ab95a301c46c636a1c 100644 (file)
@@ -37,12 +37,12 @@ public class ConvertProfileMeasuresMigrationTest {
   @ClassRule
   public static DbTester db = new DbTester().schema(ConvertProfileMeasuresMigrationTest.class, "schema.sql");
 
-  ConvertProfileMeasuresMigration migration;
+  ConvertProfileMeasuresMigrationStep migration;
 
   @Before
   public void setUp() throws Exception {
     DbClient dbClient = new DbClient(db.database(), db.myBatis());
-    migration = new ConvertProfileMeasuresMigration(dbClient);
+    migration = new ConvertProfileMeasuresMigrationStep(dbClient);
   }
 
   @Test
index 2e0bb884093ed73e440fd766b62b17d7fa7d8681..84aecc0e14db98b701282ee5cb05e76d86412fb3 100644 (file)
@@ -39,7 +39,7 @@ public class FeedQProfileDatesMigrationTest {
   @ClassRule
   public static DbTester db = new DbTester().schema(FeedQProfileDatesMigrationTest.class, "schema.sql");
 
-  FeedQProfileDatesMigration migration;
+  FeedQProfileDatesMigrationStep migration;
 
   @Before
   public void setUp() throws Exception {
@@ -48,7 +48,7 @@ public class FeedQProfileDatesMigrationTest {
     DbClient dbClient = new DbClient(db.database(), db.myBatis());
     System2 system = mock(System2.class);
     when(system.now()).thenReturn(UtcDateUtils.parseDateTime("2014-07-03T12:00:00+0000").getTime());
-    migration = new FeedQProfileDatesMigration(dbClient, system);
+    migration = new FeedQProfileDatesMigrationStep(dbClient, system);
   }
 
   @Test
index defa8783748aba549ac3f2851cea90376b113b1d..89697240cee0ceea43b18096ab8747c9e63f3f1a 100644 (file)
@@ -38,7 +38,7 @@ public class FeedQProfileKeysMigrationTest {
   public void feed_keys() throws Exception {
     db.prepareDbUnit(getClass(), "feed_keys.xml");
 
-    new FeedQProfileKeysMigration(db.database()).execute();
+    new FeedQProfileKeysMigrationStep(db.database()).execute();
 
     List<Map<String, Object>> profiles = db.select("SELECT kee, name, language, parent_kee FROM rules_profiles ORDER BY id ASC");
 
index 5ad6c22c533f1eb1aa996f37ec43a6b64f28cbf7..67331c222250313bd70707ccfa00f8f5c52d488f 100644 (file)
@@ -41,13 +41,13 @@ public class IssueActionPlanKeyMigrationTest {
   @Mock
   System2 system2;
 
-  IssueActionPlanKeyMigration migration;
+  IssueActionPlanKeyMigrationStep migration;
 
   @Before
   public void setUp() throws Exception {
     when(system2.now()).thenReturn(DateUtils.parseDate("2014-04-28").getTime());
 
-    migration = new IssueActionPlanKeyMigration(db.database(), system2);
+    migration = new IssueActionPlanKeyMigrationStep(db.database(), system2);
   }
 
   @Test
index 495746e994b3b19e8b3907d6c2611ec56a1ebbd0..33f7683fbbb78d61753a55af643718e6354dc8b1 100644 (file)
@@ -33,11 +33,11 @@ public class MeasureDataMigrationTest {
   @ClassRule
   public static DbTester db = new DbTester().schema(MeasureDataMigrationTest.class, "schema.sql");
 
-  MeasureDataMigration migration;
+  MeasureDataMigrationStep migration;
 
   @Before
   public void setUp() throws Exception {
-    migration = new MeasureDataMigration(db.database());
+    migration = new MeasureDataMigrationStep(db.database());
   }
 
   @Test
index d48dc7ccdfd4b8c039358e920681016a647d2b09..797b71f360dcbaea0eb465453b02712d1a17622a 100644 (file)
@@ -25,7 +25,7 @@ import org.junit.Test;
 import org.sonar.api.utils.DateUtils;
 import org.sonar.api.utils.System2;
 import org.sonar.core.persistence.DbTester;
-import org.sonar.server.db.migrations.DatabaseMigration;
+import org.sonar.server.db.migrations.MigrationStep;
 
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -35,7 +35,7 @@ public class AddMissingRuleParameterDefaultValuesMigrationTest {
   @ClassRule
   public static DbTester db = new DbTester().schema(AddMissingRuleParameterDefaultValuesMigrationTest.class, "schema.sql");
 
-  DatabaseMigration migration;
+  MigrationStep migration;
   System2 system = mock(System2.class);
 
   @Before
@@ -43,7 +43,7 @@ public class AddMissingRuleParameterDefaultValuesMigrationTest {
     db.executeUpdateSql("truncate table rules_parameters");
     db.executeUpdateSql("truncate table active_rules");
     db.executeUpdateSql("truncate table active_rule_parameters");
-    migration = new AddMissingRuleParameterDefaultValuesMigration(db.database(), system);
+    migration = new AddMissingRuleParameterDefaultValuesMigrationStep(db.database(), system);
     when(system.now()).thenReturn(DateUtils.parseDate("2014-04-28").getTime());
   }
 
index 6b5b85be6d16a8da4c6cc22e3903724b9399c1b5..ef1efb8ebffdb6c9b8c5e2a9c874c93411fa1c77 100644 (file)
@@ -25,7 +25,7 @@ import org.junit.ClassRule;
 import org.junit.Test;
 import org.sonar.core.persistence.DbTester;
 import org.sonar.server.db.DbClient;
-import org.sonar.server.db.migrations.DatabaseMigration;
+import org.sonar.server.db.migrations.MigrationStep;
 
 import java.sql.Connection;
 import java.sql.ResultSet;
@@ -38,12 +38,12 @@ public class DeleteMeasuresOnDeletedProfilesMigrationTest {
   @ClassRule
   public static DbTester db = new DbTester().schema(DeleteMeasuresOnDeletedProfilesMigrationTest.class, "schema.sql");
 
-  DatabaseMigration migration;
+  MigrationStep migration;
 
   @Before
   public void setUp() throws Exception {
     DbClient dbClient = new DbClient(db.database(), db.myBatis());
-    migration = new DeleteMeasuresOnDeletedProfilesMigration(dbClient);
+    migration = new DeleteMeasuresOnDeletedProfilesMigrationStep(dbClient);
   }
 
   @Test
index decad8753bba0606efdbd95693f8d057d19689d2..c55f58310c00dda86699a58790b3b1c1e0248606 100644 (file)
@@ -26,7 +26,7 @@ import org.sonar.api.utils.DateUtils;
 import org.sonar.api.utils.System2;
 import org.sonar.core.persistence.DbTester;
 import org.sonar.server.db.DbClient;
-import org.sonar.server.db.migrations.DatabaseMigration;
+import org.sonar.server.db.migrations.MigrationStep;
 
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -36,7 +36,7 @@ public class AddMissingCustomRuleParametersMigrationTest {
   @ClassRule
   public static DbTester db = new DbTester().schema(AddMissingCustomRuleParametersMigrationTest.class, "schema.sql");
 
-  DatabaseMigration migration;
+  MigrationStep migration;
   System2 system = mock(System2.class);
 
   @Before
@@ -44,7 +44,7 @@ public class AddMissingCustomRuleParametersMigrationTest {
     db.executeUpdateSql("truncate table rules");
     db.executeUpdateSql("truncate table rules_parameters");
     DbClient dbClient = new DbClient(db.database(), db.myBatis());
-    migration = new AddMissingCustomRuleParametersMigration(dbClient, system);
+    migration = new AddMissingCustomRuleParametersMigrationStep(dbClient, system);
     when(system.now()).thenReturn(DateUtils.parseDate("2014-10-09").getTime());
   }
 
index 1560bce72e4ab860a94bad2f4b889f8982577ebd..510281bde6c6587c30db29bccf0c5199fb68978f 100644 (file)
@@ -22,7 +22,7 @@ package org.sonar.server.db.migrations.v451;
 import org.junit.ClassRule;
 import org.junit.Test;
 import org.sonar.core.persistence.DbTester;
-import org.sonar.server.db.migrations.DatabaseMigration;
+import org.sonar.server.db.migrations.MigrationStep;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
@@ -31,7 +31,7 @@ public class DeleteUnescapedActivitiesTest {
   @ClassRule
   public static DbTester db = new DbTester().schema(DeleteUnescapedActivitiesTest.class, "schema.sql");
 
-  DatabaseMigration migration;
+  MigrationStep migration;
 
   @Test
   public void execute() throws Exception {
index 17b2e0ae5129b4c6d06a7532bf466b71f7fd458d..9668a68524ec64a8062b62e4a30c619e4a05b615 100644 (file)
@@ -24,7 +24,7 @@ import org.junit.ClassRule;
 import org.junit.Test;
 import org.sonar.api.utils.System2;
 import org.sonar.core.persistence.DbTester;
-import org.sonar.server.db.migrations.DatabaseMigration;
+import org.sonar.server.db.migrations.MigrationStep;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
@@ -41,7 +41,7 @@ public class FeedIssueLongDatesTest {
 
     System2 system = mock(System2.class);
     when(system.now()).thenReturn(1500000000000L);
-    DatabaseMigration migration = new FeedIssueLongDates(db.database(), system);
+    MigrationStep migration = new FeedIssueLongDates(db.database(), system);
     migration.execute();
 
     int count = db.countSql("select count(*) from issues where created_at_ms is not null and updated_at_ms is not null");
index b7ed42cc268112d589f33e5045acf2b77a5f882f..f10e6e93793230c320de91d9393d0ad5f1850649 100644 (file)
@@ -25,7 +25,7 @@ import org.junit.ClassRule;
 import org.junit.Test;
 import org.sonar.api.utils.System2;
 import org.sonar.core.persistence.DbTester;
-import org.sonar.server.db.migrations.DatabaseMigration;
+import org.sonar.server.db.migrations.MigrationStep;
 
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -35,13 +35,13 @@ public class InsertProjectsAuthorizationUpdatedAtMigrationTest {
   @ClassRule
   public static DbTester db = new DbTester().schema(InsertProjectsAuthorizationUpdatedAtMigrationTest.class, "schema.sql");
 
-  DatabaseMigration migration;
+  MigrationStep migration;
   System2 system = mock(System2.class);
 
   @Before
   public void setUp() throws Exception {
     db.executeUpdateSql("truncate table projects");
-    migration = new InsertProjectsAuthorizationUpdatedAtMigration(db.database(), system);
+    migration = new InsertProjectsAuthorizationUpdatedAtMigrationStep(db.database(), system);
     when(system.now()).thenReturn(123456789L);
   }
 
index 20aec985042b530ab306b2ae4079b316c0ea3dde..86ee10b0ed50ba41d247bb671527c97b7b7b058a 100644 (file)
@@ -30,7 +30,7 @@ import org.sonar.core.persistence.DbTester;
 import org.sonar.core.persistence.migration.v50.Component;
 import org.sonar.core.persistence.migration.v50.Migration50Mapper;
 import org.sonar.server.db.DbClient;
-import org.sonar.server.db.migrations.DatabaseMigration;
+import org.sonar.server.db.migrations.MigrationStep;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
@@ -45,7 +45,7 @@ public class PopulateProjectsUuidColumnsMigrationTest {
 
   Migration50Mapper mapper;
 
-  DatabaseMigration migration;
+  MigrationStep migration;
 
   @Before
   public void setUp() throws Exception {
@@ -54,7 +54,7 @@ public class PopulateProjectsUuidColumnsMigrationTest {
     dbClient = new DbClient(db.database(), db.myBatis());
     session = dbClient.openSession(false);
     mapper = session.getMapper(Migration50Mapper.class);
-    migration = new PopulateProjectsUuidColumnsMigration(dbClient);
+    migration = new PopulateProjectsUuidColumnsMigrationStep(dbClient);
   }
 
   @After
index f00d33d30a0288dac378af655526de2b637e6239..8c7cf3fac798352c035a46e14b305d7b9ab92afc 100644 (file)
@@ -25,7 +25,7 @@ import org.junit.Test;
 import org.sonar.api.utils.DateUtils;
 import org.sonar.api.utils.System2;
 import org.sonar.core.persistence.DbTester;
-import org.sonar.server.db.migrations.DatabaseMigration;
+import org.sonar.server.db.migrations.MigrationStep;
 
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -35,13 +35,13 @@ public class RemoveSortFieldFromIssueFiltersMigrationTest {
   @ClassRule
   public static DbTester db = new DbTester().schema(RemoveSortFieldFromIssueFiltersMigrationTest.class, "schema.sql");
 
-  DatabaseMigration migration;
+  MigrationStep migration;
   System2 system = mock(System2.class);
 
   @Before
   public void setUp() throws Exception {
     db.executeUpdateSql("truncate table issue_filters");
-    migration = new RemoveSortFieldFromIssueFiltersMigration(db.database(), system);
+    migration = new RemoveSortFieldFromIssueFiltersMigrationStep(db.database(), system);
     when(system.now()).thenReturn(DateUtils.parseDate("2014-10-29").getTime());
   }
 
index b5b3ce9abbf069c4f4655300c81e53d652df7878..5f48b08215fd0eba3b9c3cac35e3df2aea0eb953 100644 (file)
@@ -25,7 +25,7 @@ import org.junit.Test;
 import org.sonar.api.utils.DateUtils;
 import org.sonar.api.utils.System2;
 import org.sonar.core.persistence.DbTester;
-import org.sonar.server.db.migrations.DatabaseMigration;
+import org.sonar.server.db.migrations.MigrationStep;
 
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -35,7 +35,7 @@ public class ReplaceIssueFiltersProjectKeyByUuidTest {
   @ClassRule
   public static DbTester db = new DbTester().schema(ReplaceIssueFiltersProjectKeyByUuidTest.class, "schema.sql");
 
-  DatabaseMigration migration;
+  MigrationStep migration;
   System2 system = mock(System2.class);
 
   @Before
index 6559ca4eb032251a823d9748e2723d05525b6b79..e882b4a6fccb86c54ec517f5f90f57113ca03b38 100644 (file)
@@ -23,7 +23,7 @@ import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Test;
 import org.sonar.core.persistence.DbTester;
-import org.sonar.server.db.migrations.DatabaseMigration;
+import org.sonar.server.db.migrations.MigrationStep;
 
 import java.sql.Types;
 
@@ -32,7 +32,7 @@ public class AddIssuesColumnsTest {
   @ClassRule
   public static DbTester db = new DbTester().schema(AddIssuesColumnsTest.class, "schema.sql");
 
-  DatabaseMigration migration;
+  MigrationStep migration;
 
   @Before
   public void setUp() throws Exception {
index 4bc2d86983cc69824f90a515915b46292b7eb199..34fbbef067a0a7f674ff60d48a043b4dead31c5e 100644 (file)
@@ -26,7 +26,7 @@ import org.sonar.api.utils.DateUtils;
 import org.sonar.api.utils.MessageException;
 import org.sonar.api.utils.System2;
 import org.sonar.core.persistence.DbTester;
-import org.sonar.server.db.migrations.DatabaseMigration;
+import org.sonar.server.db.migrations.MigrationStep;
 
 import static junit.framework.TestCase.fail;
 import static org.assertj.core.api.Assertions.assertThat;
@@ -38,7 +38,7 @@ public class AddNewCharacteristicsTest {
   @ClassRule
   public static DbTester db = new DbTester().schema(AddNewCharacteristicsTest.class, "schema.sql");
 
-  DatabaseMigration migration;
+  MigrationStep migration;
 
   System2 system = mock(System2.class);
 
index 603f1cad8efbf06a4f2098be1c219eb6a34c2e3b..9b690506ed13cb2074fd426aa9ec1d309c2e7458 100644 (file)
@@ -26,7 +26,7 @@ import org.junit.Test;
 import org.sonar.api.utils.System2;
 import org.sonar.core.persistence.DbTester;
 import org.sonar.core.user.UserDto;
-import org.sonar.server.db.migrations.DatabaseMigration;
+import org.sonar.server.db.migrations.MigrationStep;
 
 import java.util.Map;
 
@@ -39,7 +39,7 @@ public class CopyScmAccountsFromAuthorsToUsersTest {
   @ClassRule
   public static DbTester db = new DbTester().schema(CopyScmAccountsFromAuthorsToUsersTest.class, "schema.sql");
 
-  DatabaseMigration migration;
+  MigrationStep migration;
   System2 system = mock(System2.class);
 
   @Before
index 2086736a9b8e622723bc1f21be0901a773f021a5..007c7b68ac931f66ae62c5064cb8c8732b109286 100644 (file)
@@ -24,7 +24,7 @@ import org.junit.ClassRule;
 import org.junit.Test;
 import org.sonar.api.utils.System2;
 import org.sonar.core.persistence.DbTester;
-import org.sonar.server.db.migrations.DatabaseMigration;
+import org.sonar.server.db.migrations.MigrationStep;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
@@ -40,7 +40,7 @@ public class FeedAnalysisReportsLongDatesTest {
 
     System2 system = mock(System2.class);
     when(system.now()).thenReturn(1500000000000L);
-    DatabaseMigration migration = new FeedAnalysisReportsLongDates(db.database(), system);
+    MigrationStep migration = new FeedAnalysisReportsLongDates(db.database(), system);
     migration.execute();
 
     int count = db.countSql("select count(*) from analysis_reports where created_at_ms is not null and updated_at_ms is not null");
index 4076ba2e382e4a09090009cdc5fbaa2d969b4352..c15cdfe64aa494bc72ee5be45ef81720671ae8da 100644 (file)
@@ -25,7 +25,7 @@ import org.junit.ClassRule;
 import org.junit.Test;
 import org.sonar.api.utils.System2;
 import org.sonar.core.persistence.DbTester;
-import org.sonar.server.db.migrations.DatabaseMigration;
+import org.sonar.server.db.migrations.MigrationStep;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
@@ -43,7 +43,7 @@ public class FeedEventsLongDatesTest {
 
   @Test
   public void execute() throws Exception {
-    DatabaseMigration migration = newMigration(System2.INSTANCE);
+    MigrationStep migration = newMigration(System2.INSTANCE);
 
     migration.execute();
 
@@ -59,7 +59,7 @@ public class FeedEventsLongDatesTest {
     System2 system = mock(System2.class);
     when(system.now()).thenReturn(1234L);
 
-    DatabaseMigration migration = newMigration(system);
+    MigrationStep migration = newMigration(system);
 
     migration.execute();
 
@@ -71,7 +71,7 @@ public class FeedEventsLongDatesTest {
 
   @Test
   public void take_date_if_in_the_past() throws Exception {
-    DatabaseMigration migration = newMigration(System2.INSTANCE);
+    MigrationStep migration = newMigration(System2.INSTANCE);
 
     migration.execute();
 
@@ -82,7 +82,7 @@ public class FeedEventsLongDatesTest {
     assertThat(count).isEqualTo(1);
   }
 
-  private DatabaseMigration newMigration(System2 system) {
+  private MigrationStep newMigration(System2 system) {
     return new FeedEventsLongDates(db.database(), system);
   }
 }
index c9e97998a373916beaaf725da798af2c3f6eadf2..089507fc59707f2d0e391fd1b3eb6d23ccd51158 100644 (file)
@@ -26,7 +26,7 @@ import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.sonar.core.persistence.DbTester;
 import org.sonar.core.source.db.FileSourceDto;
-import org.sonar.server.db.migrations.DatabaseMigration;
+import org.sonar.server.db.migrations.MigrationStep;
 import org.sonar.server.source.db.FileSourceDb;
 
 import java.io.InputStream;
@@ -49,7 +49,7 @@ public class FeedFileSourcesBinaryDataTest {
   public void convert_csv_to_protobuf() throws Exception {
     db.prepareDbUnit(getClass(), "data.xml");
 
-    DatabaseMigration migration = new FeedFileSourcesBinaryData(db.database());
+    MigrationStep migration = new FeedFileSourcesBinaryData(db.database());
     migration.execute();
 
     int count = db.countSql("select count(*) from file_sources where binary_data is not null");
@@ -73,7 +73,7 @@ public class FeedFileSourcesBinaryDataTest {
   public void fail_to_parse_csv() throws Exception {
     db.prepareDbUnit(getClass(), "bad_data.xml");
 
-    DatabaseMigration migration = new FeedFileSourcesBinaryData(db.database());
+    MigrationStep migration = new FeedFileSourcesBinaryData(db.database());
 
     thrown.expect(IllegalStateException.class);
     thrown.expectMessage("Error during processing of row: [id=1,data=");
index ecc00bb81ba5b2a43b6679c165723bd303f6cce8..ea5a6ada331af7b7b58786fb680efdef7f9ea407 100644 (file)
@@ -24,7 +24,7 @@ import org.junit.ClassRule;
 import org.junit.Test;
 import org.sonar.api.utils.System2;
 import org.sonar.core.persistence.DbTester;
-import org.sonar.server.db.migrations.DatabaseMigration;
+import org.sonar.server.db.migrations.MigrationStep;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
@@ -40,7 +40,7 @@ public class FeedIssueChangesLongDatesTest {
 
     System2 system = mock(System2.class);
     when(system.now()).thenReturn(1500000000000L);
-    DatabaseMigration migration = new FeedIssueChangesLongDates(db.database(), system);
+    MigrationStep migration = new FeedIssueChangesLongDates(db.database(), system);
     migration.execute();
 
     int count = db.countSql("select count(*) from issue_changes where created_at_ms is not null and updated_at_ms is not null");
index e0d3c6564e5346b8373e78116963fa0ecdcaf839..1044ad73d45cccde8e4b044caf98d9d98b3e7431 100644 (file)
@@ -24,7 +24,7 @@ import org.junit.ClassRule;
 import org.junit.Test;
 import org.sonar.api.utils.System2;
 import org.sonar.core.persistence.DbTester;
-import org.sonar.server.db.migrations.DatabaseMigration;
+import org.sonar.server.db.migrations.MigrationStep;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
@@ -39,7 +39,7 @@ public class FeedIssuesLongDatesTest {
   public void execute() throws Exception {
     db.prepareDbUnit(getClass(), "before.xml");
 
-    DatabaseMigration migration = new FeedIssuesLongDates(db.database(), System2.INSTANCE);
+    MigrationStep migration = new FeedIssuesLongDates(db.database(), System2.INSTANCE);
     migration.execute();
 
     int count = db
@@ -56,7 +56,7 @@ public class FeedIssuesLongDatesTest {
     System2 system2 = mock(System2.class);
     when(system2.now()).thenReturn(0L);
 
-    DatabaseMigration migration = new FeedIssuesLongDates(db.database(), mock(System2.class));
+    MigrationStep migration = new FeedIssuesLongDates(db.database(), mock(System2.class));
     migration.execute();
 
     int count = db
@@ -70,7 +70,7 @@ public class FeedIssuesLongDatesTest {
     db.prepareDbUnit(getClass(), "before.xml");
     long snapshotTime = parseDate("2014-09-25").getTime();
 
-    DatabaseMigration migration = new FeedIssuesLongDates(db.database(), System2.INSTANCE);
+    MigrationStep migration = new FeedIssuesLongDates(db.database(), System2.INSTANCE);
     migration.execute();
 
     int count = db
index d91efe790242415f6a4f70eb771739d02c46f5d2..1333710b31c9c1c33b48de5371720550c94375e4 100644 (file)
@@ -25,7 +25,7 @@ import org.junit.ClassRule;
 import org.junit.Test;
 import org.sonar.api.utils.System2;
 import org.sonar.core.persistence.DbTester;
-import org.sonar.server.db.migrations.DatabaseMigration;
+import org.sonar.server.db.migrations.MigrationStep;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
@@ -43,7 +43,7 @@ public class FeedManualMeasuresLongDatesTest {
 
   @Test
   public void execute() throws Exception {
-    DatabaseMigration migration = newMigration(System2.INSTANCE);
+    MigrationStep migration = newMigration(System2.INSTANCE);
 
     migration.execute();
 
@@ -59,7 +59,7 @@ public class FeedManualMeasuresLongDatesTest {
     System2 system = mock(System2.class);
     when(system.now()).thenReturn(1234L);
 
-    DatabaseMigration migration = newMigration(system);
+    MigrationStep migration = newMigration(system);
 
     migration.execute();
 
@@ -71,7 +71,7 @@ public class FeedManualMeasuresLongDatesTest {
 
   @Test
   public void take_manual_measure_date_if_in_the_past() throws Exception {
-    DatabaseMigration migration = newMigration(System2.INSTANCE);
+    MigrationStep migration = newMigration(System2.INSTANCE);
 
     migration.execute();
 
@@ -82,7 +82,7 @@ public class FeedManualMeasuresLongDatesTest {
     assertThat(count).isEqualTo(1);
   }
 
-  private DatabaseMigration newMigration(System2 system) {
+  private MigrationStep newMigration(System2 system) {
     return new FeedManualMeasuresLongDates(db.database(), system);
   }
 }
index 21f902627b14dd5daa59a856b8d58b523893f60c..010cca9be6670cde1d444b87fa504eb497288bc1 100644 (file)
@@ -25,7 +25,7 @@ import org.junit.ClassRule;
 import org.junit.Test;
 import org.sonar.api.utils.System2;
 import org.sonar.core.persistence.DbTester;
-import org.sonar.server.db.migrations.DatabaseMigration;
+import org.sonar.server.db.migrations.MigrationStep;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
@@ -43,7 +43,7 @@ public class FeedSemaphoresLongDatesTest {
 
   @Test
   public void execute() throws Exception {
-    DatabaseMigration migration = newMigration(System2.INSTANCE);
+    MigrationStep migration = newMigration(System2.INSTANCE);
 
     migration.execute();
 
@@ -60,7 +60,7 @@ public class FeedSemaphoresLongDatesTest {
     System2 system = mock(System2.class);
     when(system.now()).thenReturn(1234L);
 
-    DatabaseMigration migration = newMigration(system);
+    MigrationStep migration = newMigration(system);
 
     migration.execute();
 
@@ -72,7 +72,7 @@ public class FeedSemaphoresLongDatesTest {
 
   @Test
   public void take_snapshot_date_if_in_the_past() throws Exception {
-    DatabaseMigration migration = newMigration(System2.INSTANCE);
+    MigrationStep migration = newMigration(System2.INSTANCE);
 
     migration.execute();
 
index 24f2e73500f7b88d471a8cff0f49172f1b1f9a46..16e45e770e50610b6d474c7e20bf09c525b401b1 100644 (file)
@@ -24,7 +24,7 @@ import org.junit.ClassRule;
 import org.junit.Test;
 import org.sonar.api.utils.System2;
 import org.sonar.core.persistence.DbTester;
-import org.sonar.server.db.migrations.DatabaseMigration;
+import org.sonar.server.db.migrations.MigrationStep;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
@@ -39,7 +39,7 @@ public class FeedSnapshotsLongDatesTest {
   public void execute() throws Exception {
     db.prepareDbUnit(getClass(), "before.xml");
 
-    DatabaseMigration migration = new FeedSnapshotsLongDates(db.database(), System2.INSTANCE);
+    MigrationStep migration = new FeedSnapshotsLongDates(db.database(), System2.INSTANCE);
     migration.execute();
 
     int count = db
@@ -59,7 +59,7 @@ public class FeedSnapshotsLongDatesTest {
     System2 system2 = mock(System2.class);
     when(system2.now()).thenReturn(0L);
 
-    DatabaseMigration migration = new FeedSnapshotsLongDates(db.database(), mock(System2.class));
+    MigrationStep migration = new FeedSnapshotsLongDates(db.database(), mock(System2.class));
     migration.execute();
 
     int count = db
@@ -73,7 +73,7 @@ public class FeedSnapshotsLongDatesTest {
     db.prepareDbUnit(getClass(), "before.xml");
     long snapshotTime = parseDate("2014-09-25").getTime();
 
-    DatabaseMigration migration = new FeedSnapshotsLongDates(db.database(), System2.INSTANCE);
+    MigrationStep migration = new FeedSnapshotsLongDates(db.database(), System2.INSTANCE);
     migration.execute();
 
     int count = db
index 5a9ca798aa8a2480211bfe1a9de5458f1caf021c..e31d843500a0cc6ab96973a01fd7b23002a16969 100644 (file)
@@ -24,7 +24,7 @@ import org.junit.ClassRule;
 import org.junit.Test;
 import org.sonar.api.utils.System2;
 import org.sonar.core.persistence.DbTester;
-import org.sonar.server.db.migrations.DatabaseMigration;
+import org.sonar.server.db.migrations.MigrationStep;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
@@ -41,7 +41,7 @@ public class FeedUsersLongDatesTest {
 
     System2 system = mock(System2.class);
     when(system.now()).thenReturn(1500000000000L);
-    DatabaseMigration migration = new FeedUsersLongDates(db.database(), system);
+    MigrationStep migration = new FeedUsersLongDates(db.database(), system);
     migration.execute();
 
     int count = db.countSql("select count(*) from users where created_at_ms is not null and updated_at_ms is not null");
index 9d16460e7d3c4c5d4e5da9b23d8e1c1a4fd5c651..0dff23a0fb51ce1de3a8995e5e4407fe993f0775 100644 (file)
@@ -23,18 +23,18 @@ import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Test;
 import org.sonar.core.persistence.DbTester;
-import org.sonar.server.db.migrations.DatabaseMigration;
+import org.sonar.server.db.migrations.MigrationStep;
 
 public class RemovePermissionsOnModulesMigrationTest {
 
   @ClassRule
   public static DbTester db = new DbTester().schema(RemovePermissionsOnModulesMigrationTest.class, "schema.sql");
 
-  DatabaseMigration migration;
+  MigrationStep migration;
 
   @Before
   public void setUp() throws Exception {
-    migration = new RemovePermissionsOnModulesMigration(db.database());
+    migration = new RemovePermissionsOnModulesMigrationStep(db.database());
   }
 
   @Test
index bd8729318777435a8d958648ea0eb76fe3369531..86906e6ab5e373a0c8faff9e7a9424f91c44f593 100644 (file)
@@ -25,7 +25,7 @@ import org.junit.Test;
 import org.sonar.api.utils.DateUtils;
 import org.sonar.api.utils.System2;
 import org.sonar.core.persistence.DbTester;
-import org.sonar.server.db.migrations.DatabaseMigration;
+import org.sonar.server.db.migrations.MigrationStep;
 
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -35,7 +35,7 @@ public class RenameComponentRelatedParamsInIssueFiltersMigrationTest {
   @ClassRule
   public static DbTester db = new DbTester().schema(RenameComponentRelatedParamsInIssueFiltersMigrationTest.class, "schema.sql");
 
-  DatabaseMigration migration;
+  MigrationStep migration;
   System2 system = mock(System2.class);
 
   @Before
index 895c044a147cd70802665069e1e49922764bc422..e1d680d84640595855e685db9c10492d876abbff 100644 (file)
@@ -25,14 +25,14 @@ import org.junit.ClassRule;
 import org.junit.Test;
 import org.sonar.api.utils.System2;
 import org.sonar.core.persistence.DbTester;
-import org.sonar.server.db.migrations.DatabaseMigration;
+import org.sonar.server.db.migrations.MigrationStep;
 
 public class UpdateProjectsModuleUuidPathTest {
 
   @ClassRule
   public static DbTester db = new DbTester().schema(UpdateProjectsModuleUuidPathTest.class, "schema.sql");
 
-  DatabaseMigration migration;
+  MigrationStep migration;
 
   System2 system;
 
index 2e13dbbce8c42abcc9669b7c81d433f933ce537d..26412c877fc03dd2c403a7dd557915e87776c582 100644 (file)
@@ -24,14 +24,14 @@ import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Test;
 import org.sonar.core.persistence.DbTester;
-import org.sonar.server.db.migrations.DatabaseMigration;
+import org.sonar.server.db.migrations.MigrationStep;
 
 public class FeedEventsComponentUuidTest {
 
   @ClassRule
   public static DbTester db = new DbTester().schema(FeedEventsComponentUuidTest.class, "schema.sql");
 
-  DatabaseMigration migration;
+  MigrationStep migration;
 
   @Before
   public void setUp() throws Exception {
index 256660c7ebfbdb178794be2fa6d3624666f28d4c..76c888b19b3c8c719d5115a67d2bfd267bebf5e7 100644 (file)
@@ -24,14 +24,14 @@ import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Test;
 import org.sonar.core.persistence.DbTester;
-import org.sonar.server.db.migrations.DatabaseMigration;
+import org.sonar.server.db.migrations.MigrationStep;
 
 public class FeedProjectLinksComponentUuidTest {
 
   @ClassRule
   public static DbTester db = new DbTester().schema(FeedProjectLinksComponentUuidTest.class, "schema.sql");
 
-  DatabaseMigration migration;
+  MigrationStep migration;
 
   @Before
   public void setUp() throws Exception {
index a571bd04123c61d4c8c6a754bdd9db00e9462131..fdf30cacfe277270264ac5f72561dfdd91e2c666 100644 (file)
@@ -24,14 +24,14 @@ import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Test;
 import org.sonar.core.persistence.DbTester;
-import org.sonar.server.db.migrations.DatabaseMigration;
+import org.sonar.server.db.migrations.MigrationStep;
 
 public class MoveProjectProfileAssociationTest {
 
   @ClassRule
   public static DbTester db = new DbTester().schema(MoveProjectProfileAssociationTest.class, "schema.sql");
 
-  DatabaseMigration migration;
+  MigrationStep migration;
 
   @Before
   public void setUp() throws Exception {
index cd74986622065ad7223ce8c68c5ad5a6c0727de5..065c102f5effb4ea568dfbc2df18016cee4bfbfd 100644 (file)
@@ -32,7 +32,7 @@ class MigrateViolationsToIssues < ActiveRecord::Migration
     # Required for MSSQL to unlock the table RULE_FAILURES
     ActiveRecord::Base.connection.commit_db_transaction
 
-    execute_java_migration('org.sonar.server.db.migrations.v36.ViolationMigration')
+    execute_java_migration('org.sonar.server.db.migrations.v36.ViolationMigrationStep')
 
     # Currently not possible in Java because of Oracle (triggers and sequences must be dropped)
     drop_table('rule_failures')
index 52a1f86db9cbb2a5e83d15d2af06bc8fd7880d1f..d17ed8c28c4f20a8fcc4e052639d7d3a365810c1 100644 (file)
@@ -25,7 +25,7 @@
 class MigratePackageKeys < ActiveRecord::Migration
 
   def self.up
-    execute_java_migration('org.sonar.server.db.migrations.v42.PackageKeysMigration')
+    execute_java_migration('org.sonar.server.db.migrations.v42.PackageKeysMigrationStep')
   end
 
 end
index dd16ce162dcc573f5fa30c9a66a887229d60dbb8..3eb73f963f40f1138fe8f9b0abcba21576b999ea 100644 (file)
@@ -25,6 +25,6 @@
 class UpdateIssueMessageByRuleNameWhenNoMessage < ActiveRecord::Migration
 
   def self.up
-    execute_java_migration('org.sonar.server.db.migrations.v42.CompleteIssueMessageMigration')
+    execute_java_migration('org.sonar.server.db.migrations.v42.CompleteIssueMessageMigrationStep')
   end
 end
index c16795f24671838e92f7c698e9c087e2ed5a7f56..c02eaf1a2b58441ee9e512545186fa0bd95b10be 100644 (file)
@@ -25,6 +25,6 @@
 class ConvertIssueDebtToMinutes < ActiveRecord::Migration
 
   def self.up
-    execute_java_migration('org.sonar.server.db.migrations.v43.ConvertIssueDebtToMinutesMigration')
+    execute_java_migration('org.sonar.server.db.migrations.v43.ConvertIssueDebtToMinutesMigrationStep')
   end
 end
index 4e41841f68c6b3dadd206d016ee3fa5aeddb1759..5b755a77e44b61a37da6854f5142eee803f43439 100644 (file)
@@ -25,6 +25,6 @@
 class UpdateIssueChangelogDebtToMinutes < ActiveRecord::Migration
 
   def self.up
-    execute_java_migration('org.sonar.server.db.migrations.v43.IssueChangelogMigration')
+    execute_java_migration('org.sonar.server.db.migrations.v43.IssueChangelogMigrationStep')
   end
 end
index 80e25fc954f4da46e6729e3d4637bffaa2848aa8..fe5ed6bbec65325756051ee7ae275573700222e8 100644 (file)
@@ -25,6 +25,6 @@
 class UpdateMeasuresDebtToMinutes < ActiveRecord::Migration
 
   def self.up
-    execute_java_migration('org.sonar.server.db.migrations.v43.TechnicalDebtMeasuresMigration')
+    execute_java_migration('org.sonar.server.db.migrations.v43.TechnicalDebtMeasuresMigrationStep')
   end
 end
index d3babd54cdb1cb9160cfad25396f136003e23c62..39eca632abb6176f99081a121f7a6384bfa7f681 100644 (file)
@@ -25,6 +25,6 @@
 class UpdateDevelopmentCostToMinutes < ActiveRecord::Migration
 
   def self.up
-    execute_java_migration('org.sonar.server.db.migrations.v43.DevelopmentCostMeasuresMigration')
+    execute_java_migration('org.sonar.server.db.migrations.v43.DevelopmentCostMeasuresMigrationStep')
   end
 end
index 9d287e17578967d98a1682d19ddd862498403bf9..436e864ae635fd854b09b96be161feb9bc5dc8c4 100644 (file)
@@ -25,6 +25,6 @@
 class UpdateRequirementMeasures < ActiveRecord::Migration
 
   def self.up
-    execute_java_migration('org.sonar.server.db.migrations.v43.RequirementMeasuresMigration')
+    execute_java_migration('org.sonar.server.db.migrations.v43.RequirementMeasuresMigrationStep')
   end
 end
index 410a0bc8d2006dc6c24ad0b2e5e03c0f66743db7..778d82658a01603205faf9c229931d92f0cc46e2 100644 (file)
@@ -25,7 +25,7 @@
 class UpdateNotResolvedIssuesOnRemovedComponents < ActiveRecord::Migration
 
   def self.up
-    execute_java_migration('org.sonar.server.db.migrations.v43.NotResolvedIssuesOnRemovedComponentsMigration')
+    execute_java_migration('org.sonar.server.db.migrations.v43.NotResolvedIssuesOnRemovedComponentsMigrationStep')
   end
 
 end
index 80bd94722ca3672b9654127c46a05aa5d1b6c811..401a74ffb424aaeda0a1c923082d4a7afb16520b 100644 (file)
@@ -34,7 +34,7 @@ class MergeMeasureDataIntoProjectMeasures < ActiveRecord::Migration
       ActiveRecord::Base.connection.commit_db_transaction
     end
     ProjectMeasure.reset_column_information
-    execute_java_migration('org.sonar.server.db.migrations.v44.MeasureDataMigration')
+    execute_java_migration('org.sonar.server.db.migrations.v44.MeasureDataMigrationStep')
     drop_table(:measure_data)
   end
   
index 0add6a21944398d0405a8b0a241b23f712c703e0..479e36534ee81f809c71ef523dd5a367186f7b6e 100644 (file)
@@ -25,7 +25,7 @@
 class UpdateIssuesActionPlanKeyOnRemovedActionPlan < ActiveRecord::Migration
 
   def self.up
-    execute_java_migration('org.sonar.server.db.migrations.v44.IssueActionPlanKeyMigration')
+    execute_java_migration('org.sonar.server.db.migrations.v44.IssueActionPlanKeyMigrationStep')
   end
   
 end
index 7090686004f38a7bdaab48be3176764bff057292..d2b579ccbd8d221552e2a098ba77fd4797106cf7 100644 (file)
@@ -25,7 +25,7 @@
 class FeedQprofileKeys < ActiveRecord::Migration
 
   def self.up
-    execute_java_migration('org.sonar.server.db.migrations.v44.FeedQProfileKeysMigration')
+    execute_java_migration('org.sonar.server.db.migrations.v44.FeedQProfileKeysMigrationStep')
 
     # set as non-null and unique
     change_column :rules_profiles, :kee, :string, :limit => 255, :null => false
index a6f357c405b716b530e8d73d9ea2d0fba455cd52..1543cc3fadfbb7b2c099005930185cc8018eb5fe 100644 (file)
@@ -28,7 +28,7 @@ class ConvertProfileMeasures < ActiveRecord::Migration
   end
 
   def self.up
-    execute_java_migration('org.sonar.server.db.migrations.v44.ConvertProfileMeasuresMigration')
+    execute_java_migration('org.sonar.server.db.migrations.v44.ConvertProfileMeasuresMigrationStep')
 
     Metric.reset_column_information
     metric = Metric.find_by_name('profile')
index 0244e5730122e667803c7d0059b289bffc2030e1..d11201aee8e776e5ca291fdb55d61f3d09238f66 100644 (file)
@@ -25,7 +25,7 @@
 class UpdateLogsToActivities < ActiveRecord::Migration
 
   def self.up
-    execute_java_migration('org.sonar.server.db.migrations.v44.ChangeLogMigration')
+    execute_java_migration('org.sonar.server.db.migrations.v44.ChangeLogMigrationStep')
   end
 
 end
index 2fe4f2390f0a5f8fd27fe8346799461834c77cf6..f8cc4868a22ff1f4a86c671eb67353650f060382 100644 (file)
@@ -24,7 +24,7 @@
 class FeedQprofileDates < ActiveRecord::Migration
 
   def self.up
-    execute_java_migration 'org.sonar.server.db.migrations.v44.FeedQProfileDatesMigration'
+    execute_java_migration 'org.sonar.server.db.migrations.v44.FeedQProfileDatesMigrationStep'
   end
 
 end
index 241986a51809dfde7d81d7c7b92501bc52dc2771..e8c6f8d70dd6e4be4e1900359d09ebc526700c95 100644 (file)
@@ -24,7 +24,7 @@
 class AddMissingRuleParameterDefaultValues < ActiveRecord::Migration
 
   def self.up
-    execute_java_migration 'org.sonar.server.db.migrations.v45.AddMissingRuleParameterDefaultValuesMigration'
+    execute_java_migration 'org.sonar.server.db.migrations.v45.AddMissingRuleParameterDefaultValuesMigrationStep'
   end
 
 end
index f414494f2ba289537ad8fc586735020cb7c3c452..8a075d5fba9e9d10827346a15ccac6954d15fdaa 100644 (file)
@@ -24,7 +24,7 @@
 class DeleteMeasuresOnDeletedProfiles < ActiveRecord::Migration
 
   def self.up
-    execute_java_migration 'org.sonar.server.db.migrations.v45.DeleteMeasuresOnDeletedProfilesMigration'
+    execute_java_migration 'org.sonar.server.db.migrations.v45.DeleteMeasuresOnDeletedProfilesMigrationStep'
   end
 
 end
index 68fc21af0553824d627b03cf55f4f3d278724bef..eb41a4ff19d85b7d85c30b552d317a581802fa48 100644 (file)
@@ -25,6 +25,6 @@
 class AddMissingCustomRuleParameters < ActiveRecord::Migration
 
   def self.up
-    execute_java_migration 'org.sonar.server.db.migrations.v451.AddMissingCustomRuleParametersMigration'
+    execute_java_migration 'org.sonar.server.db.migrations.v451.AddMissingCustomRuleParametersMigrationStep'
   end
 end
index a08d370720b8a582b09c191cb7672a7f8ce036e7..6cc1aba4d0bd8f2bbd65d0e40f10a2a8d333519c 100644 (file)
@@ -25,7 +25,7 @@
 class PopulateProjectsUuidColumns < ActiveRecord::Migration
 
   def self.up
-    execute_java_migration('org.sonar.server.db.migrations.v50.PopulateProjectsUuidColumnsMigration')
+    execute_java_migration('org.sonar.server.db.migrations.v50.PopulateProjectsUuidColumnsMigrationStep')
   end
 
 end
index 365ae624d80e607139482e2e87b6efea3434deef..aec34e16e5ffbe1b183df2df14ab23934a97fc50 100644 (file)
@@ -25,7 +25,7 @@
 class InsertProjectsAuthorizationUpdatedAt < ActiveRecord::Migration
 
   def self.up
-    execute_java_migration('org.sonar.server.db.migrations.v50.InsertProjectsAuthorizationUpdatedAtMigration')
+    execute_java_migration('org.sonar.server.db.migrations.v50.InsertProjectsAuthorizationUpdatedAtMigrationStep')
   end
 
 end
index 262b9fd2c2f0409824160e6db5b6de98c3f35154..1958f9ef8de8a78ddaf07499549ba0fd567aa9bb 100644 (file)
@@ -24,7 +24,7 @@
 class RemoveSortFieldFromIssueFilters < ActiveRecord::Migration
 
   def self.up
-    execute_java_migration('org.sonar.server.db.migrations.v50.RemoveSortFieldFromIssueFiltersMigration')
+    execute_java_migration('org.sonar.server.db.migrations.v50.RemoveSortFieldFromIssueFiltersMigrationStep')
   end
 end
 
index a38e1beec91e3bab0b5bc6333da6f5d592ee6c32..9dec88eeb5cb305314f8f8ceccbb9f7b70c9979a 100644 (file)
@@ -25,7 +25,7 @@
 class RemovePermissionsOnModules < ActiveRecord::Migration
 
   def self.up
-    execute_java_migration 'org.sonar.server.db.migrations.v51.RemovePermissionsOnModulesMigration'
+    execute_java_migration 'org.sonar.server.db.migrations.v51.RemovePermissionsOnModulesMigrationStep'
   end
 
 end
index 6545ade2665efa9556afc01b83cd7f6fd7fe5b09..796cd8b6f32ba9a4acedf948f1556719a6da677b 100644 (file)
@@ -9,7 +9,7 @@ HOW TO ADD A MIGRATION
 * If a table is added or removed, then edit sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java
 * Changes in bulk must be handled using Java migrations based on org.sonar.server.db.migrations.MassUpdate :
   + Create the class for the Java migration in package package org.sonar.server.db.migrations.vXYZ, where XYZ is the version of SQ without dots
-  + Add the class to org.sonar.server.db.migrations.DatabaseMigrations.CLASSES
+  + Add the class to org.sonar.server.db.migrations.MigrationSteps.CLASSES
   + Create a Ruby migration which calls execute_java_migration('org.sonar.server.db.migrations.vXYZ.MyMigration')
   + Simple, "one to one" migrations that only need to be split by 1000 can rely on class org.sonar.server.db.migrations.BaseDataChange