aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2015-05-13 13:50:15 +0200
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2015-05-27 12:11:37 +0200
commit982931e48eafa9df8b5181729ae40bccd6ea0e9e (patch)
treeca241f74c09067f8b9c7b13147f740b3b36f0776 /server
parent2d666dab3086f7c66ca584ede46ffaf2143029ed (diff)
downloadsonarqube-982931e48eafa9df8b5181729ae40bccd6ea0e9e.tar.gz
sonarqube-982931e48eafa9df8b5181729ae40bccd6ea0e9e.zip
add module for MigrationStep
which removes ugly solo constant in interface
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/db/migrations/MigrationStep.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/db/migrations/MigrationStepModule.java (renamed from server/sonar-server/src/main/java/org/sonar/server/db/migrations/MigrationSteps.java)133
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/db/migrations/MigrationStepModuleTest.java (renamed from server/sonar-server/src/test/java/org/sonar/server/db/migrations/MigrationStepsTest.java)11
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/db/migrate/README.txt2
5 files changed, 76 insertions, 76 deletions
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
index eddf1244a55..f2c051e083c 100644
--- 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
@@ -22,7 +22,7 @@ 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}
+ * Java alternative of ActiveRecord::Migration. Do not forget to declare implementation classes in {@link MigrationStepModule}
* @since 3.7
*/
public interface MigrationStep {
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/MigrationStepModule.java
index a27a4c4bce5..cde817e8024 100644
--- 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/MigrationStepModule.java
@@ -19,7 +19,7 @@
*/
package org.sonar.server.db.migrations;
-import com.google.common.collect.ImmutableList;
+import org.sonar.core.component.Module;
import org.sonar.server.db.migrations.v36.ViolationMigrationStep;
import org.sonar.server.db.migrations.v42.CompleteIssueMessageMigrationStep;
import org.sonar.server.db.migrations.v42.PackageKeysMigrationStep;
@@ -73,78 +73,77 @@ import org.sonar.server.db.migrations.v52.FeedFileSourcesDataType;
import org.sonar.server.db.migrations.v52.FeedProjectLinksComponentUuid;
import org.sonar.server.db.migrations.v52.MoveProjectProfileAssociation;
-import java.util.List;
+public class MigrationStepModule extends Module {
+ @Override
+ protected void configureModule() {
+ add(
+ // 3.6
+ ViolationMigrationStep.class,
-public interface MigrationSteps {
+ // 4.2
+ PackageKeysMigrationStep.class, CompleteIssueMessageMigrationStep.class,
- List<Class<? extends MigrationStep>> CLASSES = ImmutableList.of(
- // 3.6
- ViolationMigrationStep.class,
+ // 4.3
+ ConvertIssueDebtToMinutesMigrationStep.class,
+ IssueChangelogMigrationStep.class,
+ TechnicalDebtMeasuresMigrationStep.class,
+ DevelopmentCostMeasuresMigrationStep.class,
+ RequirementMeasuresMigrationStep.class,
+ NotResolvedIssuesOnRemovedComponentsMigrationStep.class,
- // 4.2
- PackageKeysMigrationStep.class, CompleteIssueMessageMigrationStep.class,
+ // 4.4
+ IssueActionPlanKeyMigrationStep.class,
+ MeasureDataMigrationStep.class,
+ FeedQProfileKeysMigrationStep.class,
+ FeedQProfileDatesMigrationStep.class,
+ ChangeLogMigrationStep.class,
+ ConvertProfileMeasuresMigrationStep.class,
- // 4.3
- ConvertIssueDebtToMinutesMigrationStep.class,
- IssueChangelogMigrationStep.class,
- TechnicalDebtMeasuresMigrationStep.class,
- DevelopmentCostMeasuresMigrationStep.class,
- RequirementMeasuresMigrationStep.class,
- NotResolvedIssuesOnRemovedComponentsMigrationStep.class,
+ // 4.5
+ AddMissingRuleParameterDefaultValuesMigrationStep.class,
+ DeleteMeasuresOnDeletedProfilesMigrationStep.class,
- // 4.4
- IssueActionPlanKeyMigrationStep.class,
- MeasureDataMigrationStep.class,
- FeedQProfileKeysMigrationStep.class,
- FeedQProfileDatesMigrationStep.class,
- ChangeLogMigrationStep.class,
- ConvertProfileMeasuresMigrationStep.class,
+ // 4.5.1
+ AddMissingCustomRuleParametersMigrationStep.class,
+ DeleteUnescapedActivities.class,
- // 4.5
- AddMissingRuleParameterDefaultValuesMigrationStep.class,
- DeleteMeasuresOnDeletedProfilesMigrationStep.class,
+ // 5.0
+ InsertProjectsAuthorizationUpdatedAtMigrationStep.class,
+ PopulateProjectsUuidColumnsMigrationStep.class,
+ ReplaceIssueFiltersProjectKeyByUuid.class,
+ FeedSnapshotSourcesUpdatedAt.class,
+ FeedFileSources.class,
+ FeedIssueLongDates.class,
+ RemoveSortFieldFromIssueFiltersMigrationStep.class,
- // 4.5.1
- AddMissingCustomRuleParametersMigrationStep.class,
- DeleteUnescapedActivities.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.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,
- AddDependenciesComponentUuidColumns.class,
- FeedDependenciesComponentUuids.class,
- DropDependenciesComponentColumns.class,
- FeedFileSourcesDataType.class,
- AddDependenciesColumns.class
- );
+ // 5.2
+ FeedProjectLinksComponentUuid.class,
+ FeedEventsComponentUuid.class,
+ MoveProjectProfileAssociation.class,
+ AddDependenciesComponentUuidColumns.class,
+ FeedDependenciesComponentUuids.class,
+ DropDependenciesComponentColumns.class,
+ FeedFileSourcesDataType.class,
+ AddDependenciesColumns.class);
+ }
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java
index 379715cd497..8216f74dfa1 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java
@@ -45,7 +45,7 @@ import org.sonar.server.dashboard.db.WidgetPropertyDao;
import org.sonar.server.db.DatabaseChecker;
import org.sonar.server.db.DbClient;
import org.sonar.server.db.EmbeddedDatabaseFactory;
-import org.sonar.server.db.migrations.MigrationSteps;
+import org.sonar.server.db.migrations.MigrationStepModule;
import org.sonar.server.event.db.EventDao;
import org.sonar.server.issue.db.IssueDao;
import org.sonar.server.issue.index.IssueIndex;
@@ -158,7 +158,7 @@ public class PlatformLevel1 extends PlatformLevel {
AnalysisReportDao.class,
FileSourceDao.class);
addAll(CorePropertyDefinitions.all());
- addAll(MigrationSteps.CLASSES);
+ add(MigrationStepModule.class);
addAll(DaoUtils.getDaoClasses());
}
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/MigrationStepModuleTest.java
index 75ab0635c8f..b0522568bed 100644
--- 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/MigrationStepModuleTest.java
@@ -17,17 +17,18 @@
* 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 org.sonar.core.platform.ComponentContainer;
import static org.assertj.core.api.Assertions.assertThat;
-public class MigrationStepsTest {
-
+public class MigrationStepModuleTest {
@Test
- public void check_number_of_migrations() {
- assertThat(MigrationSteps.CLASSES).isNotEmpty();
+ public void verify_count_of_added_MigrationStep_types() throws Exception {
+ ComponentContainer container = new ComponentContainer();
+ new MigrationStepModule().configure(container);
+ assertThat(container.size()).isEqualTo(54);
}
}
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/README.txt b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/README.txt
index 796cd8b6f32..6788e4cd28c 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/README.txt
+++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/README.txt
@@ -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.MigrationSteps.CLASSES
+ + Add the class to org.sonar.server.db.migrations.MigrationStepModule
+ 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