From: Pierre Date: Fri, 8 Jul 2022 12:20:22 +0000 (+0200) Subject: Revert "SONAR-16598 Add new column generic concepts" X-Git-Tag: 9.6.0.59041~269 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0a047c1350ab811a0334b76112d3e6566fdcff2a;p=sonarqube.git Revert "SONAR-16598 Add new column generic concepts" This reverts commit e6437883f74edcaf010e713099aea38e1db52c25. --- diff --git a/server/sonar-db-dao/src/schema/schema-sq.ddl b/server/sonar-db-dao/src/schema/schema-sq.ddl index 5f0ef17e6f9..281bafab250 100644 --- a/server/sonar-db-dao/src/schema/schema-sq.ddl +++ b/server/sonar-db-dao/src/schema/schema-sq.ddl @@ -863,8 +863,7 @@ CREATE TABLE "RULES"( "AD_HOC_NAME" CHARACTER VARYING(200), "AD_HOC_DESCRIPTION" CHARACTER LARGE OBJECT, "AD_HOC_SEVERITY" CHARACTER VARYING(10), - "AD_HOC_TYPE" TINYINT, - "GENERIC_CONCEPTS" CHARACTER VARYING(255) + "AD_HOC_TYPE" TINYINT ); ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("UUID"); CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY" NULLS FIRST, "PLUGIN_NAME" NULLS FIRST); diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v96/AddGenericConceptsColumnToRuleTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v96/AddGenericConceptsColumnToRuleTable.java deleted file mode 100644 index 5011ca61b20..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v96/AddGenericConceptsColumnToRuleTable.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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.v96; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -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; - -public class AddGenericConceptsColumnToRuleTable extends DdlChange { - - static final String COLUMN_GENERIC_CONCEPTS_KEY = "generic_concepts"; - - static final String RULE_TABLE = "rules"; - - public AddGenericConceptsColumnToRuleTable(Database db) { - super(db); - } - - @Override - public void execute(DdlChange.Context context) throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - if (!DatabaseUtils.tableColumnExists(connection, RULE_TABLE, COLUMN_GENERIC_CONCEPTS_KEY)) { - context.execute(new AddColumnsBuilder(getDialect(), RULE_TABLE) - .addColumn(newVarcharColumnDefBuilder().setColumnName(COLUMN_GENERIC_CONCEPTS_KEY).setIsNullable(true).setLimit(255).build()) - .build()); - } - } - } - -} 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 043a8e38595..e8651bfc078 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 @@ -32,7 +32,6 @@ public class DbVersion96 implements DbVersion { .add(6502, "Drop unique index uniq_rule_desc_sections_kee", DropIndexForRuleDescSection.class) .add(6503, "Create unique uniq_rule_desc_sections", CreateIndexForRuleDescSections.class) .add(6504, "Add column 'expiration_date' to 'user_tokens'", AddExpirationDateColumnToUserTokens.class) - .add(6505, "Add column 'generic_concepts' to 'rules'", AddGenericConceptsColumnToRuleTable.class) ; } } diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v96/AddGenericConceptsColumnToRuleTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v96/AddGenericConceptsColumnToRuleTableTest.java deleted file mode 100644 index 4bcc490f6ce..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v96/AddGenericConceptsColumnToRuleTableTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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.v96; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -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.AddGenericConceptsColumnToRuleTable.COLUMN_GENERIC_CONCEPTS_KEY; -import static org.sonar.server.platform.db.migration.version.v96.AddGenericConceptsColumnToRuleTable.RULE_TABLE; - -public class AddGenericConceptsColumnToRuleTableTest { - @Rule - public final CoreDbTester db = createForSchema(AddGenericConceptsColumnToRuleTableTest.class, "schema.sql"); - - private final AddGenericConceptsColumnToRuleTable addGenericConceptsColumnToRuleTable = new AddGenericConceptsColumnToRuleTable(db.database()); - - @Test - public void column_generic_concepts_should_be_added() throws SQLException { - db.assertColumnDoesNotExist(RULE_TABLE, COLUMN_GENERIC_CONCEPTS_KEY); - - addGenericConceptsColumnToRuleTable.execute(); - - db.assertColumnDefinition(RULE_TABLE, COLUMN_GENERIC_CONCEPTS_KEY, Types.VARCHAR, 255, true); - } - - @Test - public void migration_should_be_reentrant() throws SQLException { - db.assertColumnDoesNotExist(RULE_TABLE, COLUMN_GENERIC_CONCEPTS_KEY); - - addGenericConceptsColumnToRuleTable.execute(); - addGenericConceptsColumnToRuleTable.execute(); - - db.assertColumnDefinition(RULE_TABLE, COLUMN_GENERIC_CONCEPTS_KEY, Types.VARCHAR, 255, true); - } -} diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v96/AddGenericConceptsColumnToRuleTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v96/AddGenericConceptsColumnToRuleTableTest/schema.sql deleted file mode 100644 index 8346f94d192..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v96/AddGenericConceptsColumnToRuleTableTest/schema.sql +++ /dev/null @@ -1,40 +0,0 @@ -CREATE TABLE "RULES"( - "UUID" CHARACTER VARYING(40) NOT NULL, - "NAME" CHARACTER VARYING(200), - "PLUGIN_RULE_KEY" CHARACTER VARYING(200) NOT NULL, - "PLUGIN_KEY" CHARACTER VARYING(200), - "PLUGIN_CONFIG_KEY" CHARACTER VARYING(200), - "PLUGIN_NAME" CHARACTER VARYING(255) NOT NULL, - "SCOPE" CHARACTER VARYING(20) NOT NULL, - "PRIORITY" INTEGER, - "STATUS" CHARACTER VARYING(40), - "LANGUAGE" CHARACTER VARYING(20), - "DEF_REMEDIATION_FUNCTION" CHARACTER VARYING(20), - "DEF_REMEDIATION_GAP_MULT" CHARACTER VARYING(20), - "DEF_REMEDIATION_BASE_EFFORT" CHARACTER VARYING(20), - "GAP_DESCRIPTION" CHARACTER VARYING(4000), - "SYSTEM_TAGS" CHARACTER VARYING(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" CHARACTER VARYING(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" CHARACTER VARYING(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "TEMPLATE_UUID" CHARACTER VARYING(40), - "NOTE_DATA" CHARACTER LARGE OBJECT, - "NOTE_USER_UUID" CHARACTER VARYING(255), - "NOTE_CREATED_AT" BIGINT, - "NOTE_UPDATED_AT" BIGINT, - "REMEDIATION_FUNCTION" CHARACTER VARYING(20), - "REMEDIATION_GAP_MULT" CHARACTER VARYING(20), - "REMEDIATION_BASE_EFFORT" CHARACTER VARYING(20), - "TAGS" CHARACTER VARYING(4000), - "AD_HOC_NAME" CHARACTER VARYING(200), - "AD_HOC_DESCRIPTION" CHARACTER LARGE OBJECT, - "AD_HOC_SEVERITY" CHARACTER VARYING(10), - "AD_HOC_TYPE" TINYINT -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY" NULLS FIRST, "PLUGIN_NAME" NULLS FIRST);