diff options
author | Benjamin Campomenosi <109955405+benjamin-campomenosi-sonarsource@users.noreply.github.com> | 2022-09-20 16:27:46 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-09-20 20:03:30 +0000 |
commit | 85aa8aca01155091f7b5a07ac3e0ed726afa2580 (patch) | |
tree | 438fc34cea347667d711c07a7fb0bacd65f2b1f2 /server/sonar-db-migration | |
parent | 6e933f99b32cd63df4899344186d1404b7fb769b (diff) | |
download | sonarqube-85aa8aca01155091f7b5a07ac3e0ed726afa2580.tar.gz sonarqube-85aa8aca01155091f7b5a07ac3e0ed726afa2580.zip |
move 9.7 DB migration to dedicated v97 subpackage
Co-authored-by: Antoine Vinot <antoine.vinot@sonarsource.com>
Diffstat (limited to 'server/sonar-db-migration')
15 files changed, 146 insertions, 19 deletions
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/MigrationConfigurationModule.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/MigrationConfigurationModule.java index 8fdfebb70ad..d6481dcbe9d 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/MigrationConfigurationModule.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/MigrationConfigurationModule.java @@ -35,6 +35,7 @@ import org.sonar.server.platform.db.migration.version.v93.DbVersion93; import org.sonar.server.platform.db.migration.version.v94.DbVersion94; import org.sonar.server.platform.db.migration.version.v95.DbVersion95; import org.sonar.server.platform.db.migration.version.v96.DbVersion96; +import org.sonar.server.platform.db.migration.version.v97.DbVersion97; public class MigrationConfigurationModule extends Module { @Override @@ -50,6 +51,7 @@ public class MigrationConfigurationModule extends Module { DbVersion94.class, DbVersion95.class, DbVersion96.class, + DbVersion97.class, // migration steps MigrationStepRegistryImpl.class, diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v96/DbVersion96.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v96/DbVersion96.java index cd3e930d2db..6352b8d0591 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v96/DbVersion96.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v96/DbVersion96.java @@ -43,9 +43,6 @@ public class DbVersion96 implements DbVersion { .add(6512, "Add column 'language' to 'push_events'", AddLanguageColumnToPushEventsTable.class) .add(6513, "Delete duplicated rows in 'project_badge_token'", DeleteDuplicatedProjectBadgeTokens.class) .add(6514, "Add unique index on 'project_uuid' in 'project_badge_token'", CreateIndexForProjectBadgeTokens.class) - .add(6515, "Add column 'webhook_secret' to 'alm_settings'", AddWebhookSecretToAlmSettingsTable.class) - .add(6516, "Drop non unique index on 'uuid' in 'components'", DropNonUniqueIndexForComponentsUuid.class) - .add(6517, "Add unique index on 'uuid' in 'components'", CreateUniqueIndexForComponentsUuid.class) ; } diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v96/AddWebhookSecretToAlmSettingsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v97/AddWebhookSecretToAlmSettingsTable.java index 708abb1d8b1..8652ceb185d 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v96/AddWebhookSecretToAlmSettingsTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v97/AddWebhookSecretToAlmSettingsTable.java @@ -17,7 +17,7 @@ * 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.v96; +package org.sonar.server.platform.db.migration.version.v97; import com.google.common.annotations.VisibleForTesting; import java.sql.Connection; @@ -29,7 +29,7 @@ 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; -import static org.sonar.server.platform.db.migration.version.v96.DbConstants.WEBHOOK_SECRET_COLUMN_SIZE; +import static org.sonar.server.platform.db.migration.version.v97.DbConstants.WEBHOOK_SECRET_COLUMN_SIZE; public class AddWebhookSecretToAlmSettingsTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v96/CreateUniqueIndexForComponentsUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v97/CreateUniqueIndexForComponentsUuid.java index 9623d6b8043..292eee7fcd6 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v96/CreateUniqueIndexForComponentsUuid.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v97/CreateUniqueIndexForComponentsUuid.java @@ -17,7 +17,7 @@ * 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.v96; +package org.sonar.server.platform.db.migration.version.v97; import com.google.common.annotations.VisibleForTesting; import java.sql.Connection; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v97/DbConstants.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v97/DbConstants.java new file mode 100644 index 00000000000..8bf178b9835 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v97/DbConstants.java @@ -0,0 +1,29 @@ +/* + * SonarQube + * Copyright (C) 2009-2022 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.v97; + +class DbConstants { + static final int CONTEXT_KEY_COLUMNS_SIZE = 50; + static final int WEBHOOK_SECRET_COLUMN_SIZE = 160; + + private DbConstants() { + throw new IllegalStateException("This class must not be instantiated"); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v97/DbVersion97.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v97/DbVersion97.java new file mode 100644 index 00000000000..0234783e802 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v97/DbVersion97.java @@ -0,0 +1,34 @@ +/* + * SonarQube + * Copyright (C) 2009-2022 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.v97; + +import org.sonar.server.platform.db.migration.step.MigrationStepRegistry; +import org.sonar.server.platform.db.migration.version.DbVersion; + +public class DbVersion97 implements DbVersion { + @Override + public void addSteps(MigrationStepRegistry registry) { + registry + .add(6600, "Add column 'webhook_secret' to 'alm_settings'", AddWebhookSecretToAlmSettingsTable.class) + .add(6601, "Drop non unique index on 'uuid' in 'components'", DropNonUniqueIndexForComponentsUuid.class) + .add(6602, "Add unique index on 'uuid' in 'components'", CreateUniqueIndexForComponentsUuid.class) + ; + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v96/DropNonUniqueIndexForComponentsUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v97/DropNonUniqueIndexForComponentsUuid.java index d29ec35f79f..552383c9042 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v96/DropNonUniqueIndexForComponentsUuid.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v97/DropNonUniqueIndexForComponentsUuid.java @@ -17,7 +17,7 @@ * 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.v96; +package org.sonar.server.platform.db.migration.version.v97; import com.google.common.annotations.VisibleForTesting; import org.sonar.db.Database; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v97/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v97/package-info.java new file mode 100644 index 00000000000..ccc15e9f8ca --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v97/package-info.java @@ -0,0 +1,24 @@ +/* + * SonarQube + * Copyright (C) 2009-2022 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. + */ +@ParametersAreNonnullByDefault +package org.sonar.server.platform.db.migration.version.v97; + +import javax.annotation.ParametersAreNonnullByDefault; + diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v96/AddWebhookSecretToAlmSettingsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v97/AddWebhookSecretToAlmSettingsTableTest.java index 536ec817ee6..3c424512ac2 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v96/AddWebhookSecretToAlmSettingsTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v97/AddWebhookSecretToAlmSettingsTableTest.java @@ -17,7 +17,7 @@ * 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.v96; +package org.sonar.server.platform.db.migration.version.v97; import java.sql.SQLException; import java.sql.Types; @@ -26,9 +26,9 @@ import org.junit.Test; import org.sonar.db.CoreDbTester; import static org.sonar.db.CoreDbTester.createForSchema; -import static org.sonar.server.platform.db.migration.version.v96.AddWebhookSecretToAlmSettingsTable.ALM_SETTINGS_TABLE_NAME; -import static org.sonar.server.platform.db.migration.version.v96.AddWebhookSecretToAlmSettingsTable.WEBHOOK_SECRET_COLUMN_NAME; -import static org.sonar.server.platform.db.migration.version.v96.DbConstants.WEBHOOK_SECRET_COLUMN_SIZE; +import static org.sonar.server.platform.db.migration.version.v97.AddWebhookSecretToAlmSettingsTable.ALM_SETTINGS_TABLE_NAME; +import static org.sonar.server.platform.db.migration.version.v97.AddWebhookSecretToAlmSettingsTable.WEBHOOK_SECRET_COLUMN_NAME; +import static org.sonar.server.platform.db.migration.version.v97.DbConstants.WEBHOOK_SECRET_COLUMN_SIZE; public class AddWebhookSecretToAlmSettingsTableTest { @@ -55,4 +55,4 @@ public class AddWebhookSecretToAlmSettingsTableTest { db.assertColumnDefinition(ALM_SETTINGS_TABLE_NAME, WEBHOOK_SECRET_COLUMN_NAME, Types.VARCHAR, WEBHOOK_SECRET_COLUMN_SIZE, true); } -}
\ No newline at end of file +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v96/CreateUniqueIndexForComponentsUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v97/CreateUniqueIndexForComponentsUuidTest.java index 9a587cb3313..9b9867fc508 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v96/CreateUniqueIndexForComponentsUuidTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v97/CreateUniqueIndexForComponentsUuidTest.java @@ -17,16 +17,16 @@ * 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.v96; +package org.sonar.server.platform.db.migration.version.v97; import java.sql.SQLException; import org.junit.Rule; import org.junit.Test; import org.sonar.db.CoreDbTester; -import static org.sonar.server.platform.db.migration.version.v96.CreateUniqueIndexForComponentsUuid.COLUMN_NAME; -import static org.sonar.server.platform.db.migration.version.v96.CreateUniqueIndexForComponentsUuid.INDEX_NAME; -import static org.sonar.server.platform.db.migration.version.v96.CreateUniqueIndexForComponentsUuid.TABLE; +import static org.sonar.server.platform.db.migration.version.v97.CreateUniqueIndexForComponentsUuid.COLUMN_NAME; +import static org.sonar.server.platform.db.migration.version.v97.CreateUniqueIndexForComponentsUuid.INDEX_NAME; +import static org.sonar.server.platform.db.migration.version.v97.CreateUniqueIndexForComponentsUuid.TABLE; public class CreateUniqueIndexForComponentsUuidTest { diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v97/DbVersion97Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v97/DbVersion97Test.java new file mode 100644 index 00000000000..003bb20bd16 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v97/DbVersion97Test.java @@ -0,0 +1,41 @@ +/* + * SonarQube + * Copyright (C) 2009-2022 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.v97; + +import org.junit.Test; + +import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationNotEmpty; +import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber; + +public class DbVersion97Test { + + private final DbVersion97 underTest = new DbVersion97(); + + @Test + public void migrationNumber_starts_at_6600() { + verifyMinimumMigrationNumber(underTest, 6600); + } + + @Test + public void verify_migration_is_not_empty() { + verifyMigrationNotEmpty(underTest); + } + +}
\ No newline at end of file diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v96/DropNonUniqueIndexForComponentsUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v97/DropNonUniqueIndexForComponentsUuidTest.java index bbc326c95c6..44d54bf9a40 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v96/DropNonUniqueIndexForComponentsUuidTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v97/DropNonUniqueIndexForComponentsUuidTest.java @@ -17,15 +17,15 @@ * 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.v96; +package org.sonar.server.platform.db.migration.version.v97; import java.sql.SQLException; import org.junit.Rule; import org.junit.Test; import org.sonar.db.CoreDbTester; -import static org.sonar.server.platform.db.migration.version.v96.DropNonUniqueIndexForComponentsUuid.INDEX_NAME; -import static org.sonar.server.platform.db.migration.version.v96.DropNonUniqueIndexForComponentsUuid.TABLE; +import static org.sonar.server.platform.db.migration.version.v97.DropNonUniqueIndexForComponentsUuid.INDEX_NAME; +import static org.sonar.server.platform.db.migration.version.v97.DropNonUniqueIndexForComponentsUuid.TABLE; public class DropNonUniqueIndexForComponentsUuidTest { diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v96/AddWebhookSecretToAlmSettingsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v97/AddWebhookSecretToAlmSettingsTableTest/schema.sql index ac2de3480f7..ac2de3480f7 100644 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v96/AddWebhookSecretToAlmSettingsTableTest/schema.sql +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v97/AddWebhookSecretToAlmSettingsTableTest/schema.sql diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v96/CreateUniqueIndexForComponentsUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v97/CreateUniqueIndexForComponentsUuidTest/schema.sql index 2d6834b6b0b..2d6834b6b0b 100644 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v96/CreateUniqueIndexForComponentsUuidTest/schema.sql +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v97/CreateUniqueIndexForComponentsUuidTest/schema.sql diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v96/DropNonUniqueIndexForComponentsUuidTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v97/DropNonUniqueIndexForComponentsUuidTest/schema.sql index 0fa3c25db24..0fa3c25db24 100644 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v96/DropNonUniqueIndexForComponentsUuidTest/schema.sql +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v97/DropNonUniqueIndexForComponentsUuidTest/schema.sql |