diff options
author | Janos Gyerik <janos.gyerik@sonarsource.com> | 2019-03-18 14:29:36 +0100 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2019-03-19 20:21:27 +0100 |
commit | 4d41ea378118db73f4e807b05f2698209a76102d (patch) | |
tree | 50d7fd31cc871fb8d8ba8dc119cb47239df33294 | |
parent | eed6bc73b6569f0dd624ae58ad141f7702878557 (diff) | |
download | sonarqube-4d41ea378118db73f4e807b05f2698209a76102d.tar.gz sonarqube-4d41ea378118db73f4e807b05f2698209a76102d.zip |
SONAR-11823 Drop snapshots.project_version
19 files changed, 151 insertions, 29 deletions
diff --git a/server/sonar-db-core/src/main/resources/org/sonar/db/version/schema-h2.ddl b/server/sonar-db-core/src/main/resources/org/sonar/db/version/schema-h2.ddl index 80c4b377e4d..aa57ac9a70d 100644 --- a/server/sonar-db-core/src/main/resources/org/sonar/db/version/schema-h2.ddl +++ b/server/sonar-db-core/src/main/resources/org/sonar/db/version/schema-h2.ddl @@ -142,7 +142,6 @@ CREATE TABLE "SNAPSHOTS" ( "PURGE_STATUS" INTEGER, "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, "VERSION" VARCHAR(500), - "PROJECT_VERSION" VARCHAR(100), "BUILD_STRING" VARCHAR(100), "PERIOD1_MODE" VARCHAR(100), "PERIOD1_PARAM" VARCHAR(100), diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteResource.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteResource.xml index af7588f557e..3660be0b472 100644 --- a/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteResource.xml +++ b/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteResource.xml @@ -42,7 +42,7 @@ created_at="1228222680000" build_date="1228222680000" version="[null]" - project_version="[null]" + build_string="[null]" /> <analysis_properties uuid="u1" diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingAnalysis.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingAnalysis.xml index 8bee951c35b..f4227cf96ca 100644 --- a/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingAnalysis.xml +++ b/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingAnalysis.xml @@ -52,7 +52,7 @@ created_at="1228222680000" build_date="1228222680000" version="[null]" - project_version="[null]" + build_string="[null]" /> <!-- do not delete standard measure --> diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldPurgeAnalysis-result.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldPurgeAnalysis-result.xml index e9e512f02d2..b61837e660b 100644 --- a/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldPurgeAnalysis-result.xml +++ b/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldPurgeAnalysis-result.xml @@ -32,7 +32,6 @@ Note that measures, events and reviews are not deleted. created_at="1228222680000" build_date="1228222680000" version="[null]" - project_version="[null]" build_string="[null]" /> <analysis_properties uuid="u1" @@ -106,7 +105,7 @@ Note that measures, events and reviews are not deleted. created_at="1228222680000" build_date="1228222680000" version="[null]" - project_version="[null]" + build_string="[null]" /> <analysis_properties uuid="u2" diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldPurgeAnalysis.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldPurgeAnalysis.xml index b6b9c78349f..44d70d4f14f 100644 --- a/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldPurgeAnalysis.xml +++ b/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldPurgeAnalysis.xml @@ -24,7 +24,7 @@ created_at="1228222680000" build_date="1228222680000" version="[null]" - project_version="[null]" + build_string="[null]" /> <analysis_properties uuid="u1" @@ -98,7 +98,7 @@ created_at="1228222680000" build_date="1228222680000" version="[null]" - project_version="[null]" + build_string="[null]" /> <analysis_properties uuid="u2" diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteAbortedBuilds-result.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteAbortedBuilds-result.xml index c70adbbf836..9d3afbaa225 100644 --- a/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteAbortedBuilds-result.xml +++ b/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteAbortedBuilds-result.xml @@ -50,7 +50,6 @@ Snapshot 2 has been deleted created_at="1228222680000" build_date="1228222680000" version="[null]" - project_version="[null]" build_string="[null]" /> @@ -79,7 +78,7 @@ Snapshot 2 has been deleted created_at="1228222680000" build_date="1228222680000" version="[null]" - project_version="[null]" + build_string="[null]" /> </dataset> diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteAbortedBuilds.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteAbortedBuilds.xml index 99b17569bae..bd9d1ecdbd8 100644 --- a/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteAbortedBuilds.xml +++ b/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteAbortedBuilds.xml @@ -45,7 +45,7 @@ created_at="1228222680000" build_date="1228222680000" version="[null]" - project_version="[null]" + build_string="[null]" /> <!-- snapshot with status "unprocessed" -> to be deleted --> @@ -73,7 +73,7 @@ created_at="1228222680000" build_date="1228222680000" version="[null]" - project_version="[null]" + build_string="[null]" /> <!-- snapshot with status "processed" and flagged as "last" -> do not purge and do not delete --> @@ -101,7 +101,7 @@ created_at="1228222680000" build_date="1228222680000" version="[null]" - project_version="[null]" + build_string="[null]" /> </dataset> diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteAnalyses-result.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteAnalyses-result.xml index 16a0bab013e..aa7d13e08f5 100644 --- a/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteAnalyses-result.xml +++ b/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteAnalyses-result.xml @@ -25,7 +25,6 @@ created_at="1228222680000" build_date="1228222680000" version="[null]" - project_version="[null]" build_string="[null]" /> @@ -54,7 +53,7 @@ created_at="1228222680000" build_date="1228222680000" version="[null]" - project_version="[null]" + build_string="[null]" /> </dataset> diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteAnalyses.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteAnalyses.xml index 7aa4af52e0c..51673c1b529 100644 --- a/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteAnalyses.xml +++ b/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteAnalyses.xml @@ -25,7 +25,7 @@ created_at="1228222680000" build_date="1228222680000" version="[null]" - project_version="[null]" + build_string="[null]" /> <!-- delete only resource 1 --> @@ -53,7 +53,7 @@ created_at="1228222680000" build_date="1228222680000" version="[null]" - project_version="[null]" + build_string="[null]" /> <!-- to be deleted --> @@ -81,7 +81,7 @@ created_at="1228222680000" build_date="1228222680000" version="[null]" - project_version="[null]" + build_string="[null]" /> </dataset> diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles-result.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles-result.xml index 39fe34d21c7..cbfd274de16 100644 --- a/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles-result.xml +++ b/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles-result.xml @@ -185,7 +185,6 @@ created_at="1228222680000" build_date="1228222680000" version="[null]" - project_version="[null]" build_string="[null]" /> @@ -279,7 +278,7 @@ created_at="1228222680000" build_date="1228222680000" version="[null]" - project_version="[null]" + build_string="[null]" /> <project_measures id="5" diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles.xml index 67c496411aa..8f08b4a5f5d 100644 --- a/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles.xml +++ b/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles.xml @@ -185,7 +185,7 @@ created_at="1228222680000" build_date="1228222680000" version="[null]" - project_version="[null]" + build_string="[null]" /> <project_measures id="1" @@ -278,7 +278,7 @@ created_at="1228222680000" build_date="1228222680000" version="[null]" - project_version="[null]" + build_string="[null]" /> <project_measures id="5" diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteProject.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteProject.xml index 7cff4413e5e..78f130d8df3 100644 --- a/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteProject.xml +++ b/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteProject.xml @@ -58,7 +58,7 @@ created_at="1228222680000" build_date="1228222680000" version="[null]" - project_version="[null]" + build_string="[null]" /> <issues id="1" diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldPurgeProject-result.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldPurgeProject-result.xml index 7f10558d0a9..3d7fd311f93 100644 --- a/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldPurgeProject-result.xml +++ b/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldPurgeProject-result.xml @@ -66,7 +66,6 @@ created_at="1228222680000" build_date="1228222680000" version="[null]" - project_version="[null]" build_string="[null]" /> @@ -96,7 +95,7 @@ created_at="1228222680000" build_date="1228222680000" version="[null]" - project_version="[null]" + build_string="[null]" /> <!-- snapshot to be purged --> @@ -124,7 +123,7 @@ created_at="1228222680000" build_date="1228222680000" version="[null]" - project_version="[null]" + build_string="[null]" /> </dataset> diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldPurgeProject.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldPurgeProject.xml index 7362c125b54..f63f25501cf 100644 --- a/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldPurgeProject.xml +++ b/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldPurgeProject.xml @@ -65,7 +65,7 @@ created_at="1228222680000" build_date="1228222680000" version="[null]" - project_version="[null]" + build_string="[null]" /> @@ -94,7 +94,7 @@ created_at="1228222680000" build_date="1228222680000" version="[null]" - project_version="[null]" + build_string="[null]" /> <!-- snapshot to be purged --> @@ -122,7 +122,7 @@ created_at="1228222680000" build_date="1228222680000" version="[null]" - project_version="[null]" + build_string="[null]" /> </dataset> diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/DbVersion77.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/DbVersion77.java index c12afef8e3b..4c31fe89a78 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/DbVersion77.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/DbVersion77.java @@ -39,6 +39,8 @@ public class DbVersion77 implements DbVersion { .add(2609, "Delete exceeding favorites when there are more than 100 for a user", DeleteFavoritesExceedingOneHundred.class) .add(2610, "Truncate ES_QUEUE table content", TruncateEsQueue.class) .add(2611, "Add SNAPSHOTS.BUILD_STRING", AddBuildStringToSnapshot.class) + // FIXME after deployment on SonarCloud, drop this and "Add SNAPSHOTS.PROJECT_VERSION" above as they cancel out each other + .add(2612, "Drop SNAPSHOTS.PROJECT_VERSION", DropProjectVersionFromSnapshots.class) ; } } diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/DropProjectVersionFromSnapshots.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/DropProjectVersionFromSnapshots.java new file mode 100644 index 00000000000..ff55ba431f9 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/DropProjectVersionFromSnapshots.java @@ -0,0 +1,40 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v77; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropProjectVersionFromSnapshots extends DdlChange { + + private static final String TABLE_NAME = "snapshots"; + + public DropProjectVersionFromSnapshots(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDialect(), TABLE_NAME, "project_version") + .build()); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/DbVersion77Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/DbVersion77Test.java index 802d22d59a3..c3245e62a98 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/DbVersion77Test.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/DbVersion77Test.java @@ -36,7 +36,7 @@ public class DbVersion77Test { @Test public void verify_migration_count() { - verifyMigrationCount(underTest, 12); + verifyMigrationCount(underTest, 13); } } diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/DropProjectVersionFromSnapshotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/DropProjectVersionFromSnapshotsTest.java new file mode 100644 index 00000000000..e4787ade0f9 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/DropProjectVersionFromSnapshotsTest.java @@ -0,0 +1,56 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonar.server.platform.db.migration.version.v77; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.db.CoreDbTester; + +public class DropProjectVersionFromSnapshotsTest { + + private static final String TABLE = "snapshots"; + + @Rule + public final CoreDbTester db = CoreDbTester.createForSchema(DropProjectVersionFromSnapshotsTest.class, "snapshots.sql"); + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + private DropProjectVersionFromSnapshots underTest = new DropProjectVersionFromSnapshots(db.database()); + + @Test + public void drop_column_and_recreate_index() throws SQLException { + underTest.execute(); + + db.assertColumnDoesNotExist(TABLE, "project_version"); + } + + @Test + public void migration_is_not_re_entrant() throws SQLException { + underTest.execute(); + + expectedException.expect(IllegalStateException.class); + + underTest.execute(); + } + +} diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/DropProjectVersionFromSnapshotsTest/snapshots.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/DropProjectVersionFromSnapshotsTest/snapshots.sql new file mode 100644 index 00000000000..8d668abd1d8 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/DropProjectVersionFromSnapshotsTest/snapshots.sql @@ -0,0 +1,30 @@ +CREATE TABLE "SNAPSHOTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "UUID" VARCHAR(50) NOT NULL, + "CREATED_AT" BIGINT, + "BUILD_DATE" BIGINT, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', + "PURGE_STATUS" INTEGER, + "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, + "VERSION" VARCHAR(500), + "PROJECT_VERSION" VARCHAR(100), + "BUILD_STRING" VARCHAR(100), + "PERIOD1_MODE" VARCHAR(100), + "PERIOD1_PARAM" VARCHAR(100), + "PERIOD1_DATE" BIGINT, + "PERIOD2_MODE" VARCHAR(100), + "PERIOD2_PARAM" VARCHAR(100), + "PERIOD2_DATE" BIGINT, + "PERIOD3_MODE" VARCHAR(100), + "PERIOD3_PARAM" VARCHAR(100), + "PERIOD3_DATE" BIGINT, + "PERIOD4_MODE" VARCHAR(100), + "PERIOD4_PARAM" VARCHAR(100), + "PERIOD4_DATE" BIGINT, + "PERIOD5_MODE" VARCHAR(100), + "PERIOD5_PARAM" VARCHAR(100), + "PERIOD5_DATE" BIGINT +); +CREATE INDEX "SNAPSHOT_COMPONENT" ON "SNAPSHOTS" ("COMPONENT_UUID"); +CREATE UNIQUE INDEX "ANALYSES_UUID" ON "SNAPSHOTS" ("UUID"); |