aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJanos Gyerik <janos.gyerik@sonarsource.com>2019-04-08 09:53:44 +0200
committerSonarTech <sonartech@sonarsource.com>2019-04-08 20:21:07 +0200
commitf427b95bfa6dfc8dadcccf949812dc76d0770178 (patch)
tree8f33bace39f2838bcd261dd216752aa45df8e239
parent497c52c32eec22b058284e3d51ff775f3be2cbcc (diff)
downloadsonarqube-f427b95bfa6dfc8dadcccf949812dc76d0770178.tar.gz
sonarqube-f427b95bfa6dfc8dadcccf949812dc76d0770178.zip
Drop redundant migrations
-rw-r--r--server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/AddProjectVersionToSnapshot.java50
-rw-r--r--server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/DbVersion77.java3
-rw-r--r--server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/DropProjectVersionFromSnapshots.java40
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/AddProjectVersionToSnapshotTest.java57
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/DbVersion77Test.java2
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/DropProjectVersionFromSnapshotsTest.java56
-rw-r--r--server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/AddProjectVersionToSnapshotTest/snapshots.sql28
-rw-r--r--server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/DropProjectVersionFromSnapshotsTest/snapshots.sql30
8 files changed, 1 insertions, 265 deletions
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/AddProjectVersionToSnapshot.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/AddProjectVersionToSnapshot.java
deleted file mode 100644
index 3f53783f037..00000000000
--- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/AddProjectVersionToSnapshot.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.SupportsBlueGreen;
-import org.sonar.server.platform.db.migration.def.VarcharColumnDef;
-import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder;
-import org.sonar.server.platform.db.migration.step.DdlChange;
-
-import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder;
-
-@SupportsBlueGreen
-public class AddProjectVersionToSnapshot extends DdlChange {
- private static final String TABLE_NAME = "snapshots";
- private static final VarcharColumnDef COLUMN_PROJECT_VERSION = newVarcharColumnDefBuilder()
- .setColumnName("project_version")
- .setIsNullable(true)
- .setLimit(100)
- .build();
-
- public AddProjectVersionToSnapshot(Database db) {
- super(db);
- }
-
- @Override
- public void execute(Context context) throws SQLException {
- context.execute(new AddColumnsBuilder(getDialect(), TABLE_NAME)
- .addColumn(COLUMN_PROJECT_VERSION)
- .build());
- }
-}
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 4c31fe89a78..92c5e0d9e84 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
@@ -32,15 +32,12 @@ public class DbVersion77 implements DbVersion {
.add(2602, "Add column LAST_CONNECTION_DATE to USERS table", AddLastConnectionDateToUsers.class)
.add(2603, "Add column LAST_USED_DATE to USER_TOKENS table", AddLastConnectionDateToUserTokens.class)
.add(2604, "Add baseline columns in PROJECT_BRANCHES", AddManualBaselineToProjectBranches.class)
- .add(2605, "Add SNAPSHOTS.PROJECT_VERSION", AddProjectVersionToSnapshot.class)
.add(2606, "Drop DATA_TYPE column from FILE_SOURCES table", DropDataTypeFromFileSources.class)
.add(2607, "Add MEMBERS_SYNC_ENABLED column to ORGANIZATIONS_ALM_BINDING table", AddMembersSyncFlagToOrgAlmBinding.class)
.add(2608, "Delete favorites on not supported components", DeleteFavouritesOnNotSupportedComponentQualifiers.class)
.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
deleted file mode 100644
index ff55ba431f9..00000000000
--- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v77/DropProjectVersionFromSnapshots.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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/AddProjectVersionToSnapshotTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/AddProjectVersionToSnapshotTest.java
deleted file mode 100644
index 9e7972c64ca..00000000000
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/AddProjectVersionToSnapshotTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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;
-
-import static java.sql.Types.VARCHAR;
-
-public class AddProjectVersionToSnapshotTest {
-
- private static final String TABLE = "snapshots";
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
- @Rule
- public final CoreDbTester db = CoreDbTester.createForSchema(AddProjectVersionToSnapshotTest.class, "snapshots.sql");
-
- private AddProjectVersionToSnapshot underTest = new AddProjectVersionToSnapshot(db.database());
-
- @Test
- public void creates_table_on_empty_db() throws SQLException {
- underTest.execute();
-
- db.assertColumnDefinition(TABLE, "project_version", VARCHAR, 100, true);
- }
-
- @Test
- public void migration_is_not_reentrant() throws SQLException {
- underTest.execute();
-
- expectedException.expect(IllegalStateException.class);
-
- underTest.execute();
- }
-
-}
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 c3245e62a98..001eef0e521 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, 13);
+ verifyMigrationCount(underTest, 11);
}
}
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
deleted file mode 100644
index e4787ade0f9..00000000000
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v77/DropProjectVersionFromSnapshotsTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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/AddProjectVersionToSnapshotTest/snapshots.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/AddProjectVersionToSnapshotTest/snapshots.sql
deleted file mode 100644
index 7d8f2963a86..00000000000
--- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/AddProjectVersionToSnapshotTest/snapshots.sql
+++ /dev/null
@@ -1,28 +0,0 @@
-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),
- "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");
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
deleted file mode 100644
index 8d668abd1d8..00000000000
--- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v77/DropProjectVersionFromSnapshotsTest/snapshots.sql
+++ /dev/null
@@ -1,30 +0,0 @@
-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");