.add(6111, "Change size of column 'kee' in 'components'", AlterKeeInComponentsTable.class)
.add(6112, "Create 'project_badge_token' Table", CreateProjectBadgeTokenTable.class)
.add(6113, "Deprecate quality profile 'Sonar way Recommended' for js and ts", DeprecateSWRecommendedQProfile.class)
+ .add(6114, "Drop the 'sonar.lf.aboutText' property value", DropSonarLfAboutTextPropertyValue.class)
;
}
}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2021 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.v92;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DataChange;
+
+public class DropSonarLfAboutTextPropertyValue extends DataChange {
+
+ public static final String PROPERTY_TO_DELETE_KEY = "sonar.lf.aboutText";
+
+ public DropSonarLfAboutTextPropertyValue(Database db) {
+ super(db);
+ }
+
+ @Override
+ public void execute(Context context) throws SQLException {
+ context
+ .prepareUpsert("delete from properties where prop_key = ?")
+ .setString(1, PROPERTY_TO_DELETE_KEY)
+ .execute()
+ .commit();
+ }
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2021 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.v92;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.core.util.SequenceUuidFactory;
+import org.sonar.core.util.UuidFactory;
+import org.sonar.db.CoreDbTester;
+import org.sonar.server.platform.db.migration.step.DataChange;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatCode;
+
+public class DropSonarLfAboutTextPropertyTest {
+
+ private final UuidFactory uuidFactory = new SequenceUuidFactory();
+
+ @Rule
+ public final CoreDbTester db = CoreDbTester.createForSchema(DropSonarLfAboutTextPropertyTest.class, "schema.sql");
+
+ private final DataChange underTest = new DropSonarLfAboutTextPropertyValue(db.database());
+
+ @Test
+ public void do_not_fail_if_no_rows_to_delete() {
+ assertThatCode(underTest::execute)
+ .doesNotThrowAnyException();
+ }
+
+ @Test
+ public void deletes_lf_about_text_property_when_they_exist_in_database() throws SQLException {
+ insertProperty(DropSonarLfAboutTextPropertyValue.PROPERTY_TO_DELETE_KEY, "This is an about text test sample");
+
+ underTest.execute();
+
+ assertThat(db.countSql(
+ String.format("select count(*) from properties where prop_key = '%s'",
+ DropSonarLfAboutTextPropertyValue.PROPERTY_TO_DELETE_KEY
+ ))).isZero();
+ }
+
+ private void insertProperty(String key, String value) {
+ db.executeInsert("properties",
+ "PROP_KEY", key,
+ "TEXT_VALUE", value,
+ "IS_EMPTY", String.valueOf(false),
+ "CREATED_AT", 2,
+ "UUID", uuidFactory.create());
+ }
+}
--- /dev/null
+CREATE TABLE "PROPERTIES"(
+ "PROP_KEY" VARCHAR(512) NOT NULL,
+ "IS_EMPTY" BOOLEAN NOT NULL,
+ "TEXT_VALUE" VARCHAR(4000) NULL,
+ "CLOB_VALUE" VARCHAR(4000) NULL,
+ "CREATED_AT" INTEGER NOT NULL,
+ "COMPONENT_UUID" VARCHAR(40) NULL,
+ "UUID" VARCHAR(40) NOT NULL,
+ "USER_UUID" VARCHAR(255) NULL
+);
.category(CoreProperties.CATEGORY_GENERAL)
.subCategory(CoreProperties.SUBCATEGORY_LOOKNFEEL)
.build(),
- PropertyDefinition.builder(WebConstants.SONAR_LF_ABOUT_TEXT)
- .name("About page text")
- .description("Optional text that is displayed on the About page. Supports html.")
- .category(CoreProperties.CATEGORY_GENERAL)
- .subCategory(CoreProperties.SUBCATEGORY_LOOKNFEEL)
- .type(PropertyType.TEXT)
- .build(),
// ISSUES
PropertyDefinition.builder(CoreProperties.DEVELOPER_AGGREGATED_INFO_DISABLED)
public static final String SONAR_LF_GRAVATAR_SERVER_URL = "sonar.lf.gravatarServerUrl";
public static final String SONAR_LF_LOGO_URL = "sonar.lf.logoUrl";
public static final String SONAR_LF_LOGO_WIDTH_PX = "sonar.lf.logoWidthPx";
- public static final String SONAR_LF_ABOUT_TEXT = "sonar.lf.aboutText";
private WebConstants() {
}
@Test
public void all() {
List<PropertyDefinition> defs = CorePropertyDefinitions.all();
- assertThat(defs).hasSize(53);
+ assertThat(defs).hasSize(52);
}
@Test