"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);
+++ /dev/null
-/*
- * 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());
- }
- }
- }
-
-}
.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)
;
}
}
+++ /dev/null
-/*
- * 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);
- }
-}
+++ /dev/null
-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);