diff options
author | Javier Garcia Orduna <javier.garcia@sonarsource.com> | 2024-10-14 14:36:35 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2024-10-14 20:03:04 +0000 |
commit | 10e37ca6cfe52d7419852de698ac67993b0f01c4 (patch) | |
tree | eae766e9333ff85bd976d343e080a603f45a3bf4 /server/sonar-db-migration | |
parent | 74259ee57156531a69177e6bb7ac0186797d9ad9 (diff) | |
download | sonarqube-10e37ca6cfe52d7419852de698ac67993b0f01c4.tar.gz sonarqube-10e37ca6cfe52d7419852de698ac67993b0f01c4.zip |
SONAR-23312 Drop column issues.from_hotspot
Diffstat (limited to 'server/sonar-db-migration')
3 files changed, 85 insertions, 1 deletions
diff --git a/server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v108/DropColumnFromHotspotInIssuesIT.java b/server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v108/DropColumnFromHotspotInIssuesIT.java new file mode 100644 index 00000000000..9aef15ead25 --- /dev/null +++ b/server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v108/DropColumnFromHotspotInIssuesIT.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2024 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.v108; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.sonar.db.MigrationDbTester; +import org.sonar.server.platform.db.migration.step.DdlChange; + +class DropColumnFromHotspotInIssuesIT { + private static final String TABLE_NAME = "issues"; + private static final String COLUMN_NAME = "from_hotspot"; + + @RegisterExtension + public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(DropColumnFromHotspotInIssues.class); + private final DdlChange underTest = new DropColumnFromHotspotInIssues(db.database()); + + @Test + void drops_column() throws SQLException { + db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.BOOLEAN, null, true); + underTest.execute(); + db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME); + } + + @Test + void migration_is_reentrant() throws SQLException { + db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.BOOLEAN, null, true); + underTest.execute(); + underTest.execute(); + db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v108/DbVersion108.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v108/DbVersion108.java index b908e920137..2d001f4d95e 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v108/DbVersion108.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v108/DbVersion108.java @@ -48,7 +48,8 @@ public class DbVersion108 implements DbVersion { .add(10_8_005, "Create index on 'portfolios.measures_migrated'", CreateIndexOnPortfoliosMeasuresMigrated.class) .add(10_8_006, "Migrate the content of 'live_measures' to 'measures' for portfolios", MigratePortfoliosLiveMeasuresToMeasures.class) .add(10_8_007, "Create primary key on 'measures' table", CreatePrimaryKeyOnMeasuresTable.class) - .add(10_8_008, "Create index on column 'branch_uuid' in 'measures' table", CreateIndexOnMeasuresTable.class); + .add(10_8_008, "Create index on column 'branch_uuid' in 'measures' table", CreateIndexOnMeasuresTable.class) + .add(10_8_009, "Drop column 'from_hotspot' in the 'issues' table", DropColumnFromHotspotInIssues.class); } } diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v108/DropColumnFromHotspotInIssues.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v108/DropColumnFromHotspotInIssues.java new file mode 100644 index 00000000000..bb30891e5d9 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v108/DropColumnFromHotspotInIssues.java @@ -0,0 +1,32 @@ +/* + * SonarQube + * Copyright (C) 2009-2024 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.v108; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DropColumnChange; + +public class DropColumnFromHotspotInIssues extends DropColumnChange { + private static final String COLUMN_NAME = "from_hotspot"; + private static final String TABLE_NAME = "issues"; + + public DropColumnFromHotspotInIssues(Database db) { + super(db, TABLE_NAME, COLUMN_NAME); + } +} |