INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1617');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1618');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1619');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1620');
INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, EXTERNAL_IDENTITY, EXTERNAL_IDENTITY_PROVIDER, USER_LOCAL, CRYPTED_PASSWORD, SALT, IS_ROOT, CREATED_AT, UPDATED_AT) VALUES (1, 'admin', 'Administrator', '', 'admin', 'sonarqube', true, 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', false, '1418215735482', '1418215735482');
ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2;
.add(1617, "Drop metadata columns from RULES", DropMetadataColumnsFromRules.class)
// ensure the index is made unique even on existing 6.4-SNAPSHOT instances (such as next or the developer machines)
.add(1618, "Make index on ORGANIZATIONS.KEE unique", org.sonar.server.platform.db.migration.version.v63.MakeIndexOnOrganizationsKeeUnique.class)
- .add(1619, "Restore 'sonar-users' group", RestoreSonarUsersGroups.class);
+ .add(1619, "Restore 'sonar-users' group", RestoreSonarUsersGroups.class)
+ .add(1620, "Delete 'sonar.defaultGroup' setting", DeleteDefaultGroupSetting.class);
}
}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 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.v64;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DataChange;
+
+public class DeleteDefaultGroupSetting extends DataChange {
+
+ public DeleteDefaultGroupSetting(Database db) {
+ super(db);
+ }
+
+ @Override
+ protected void execute(Context context) throws SQLException {
+ context.prepareUpsert("DELETE FROM properties WHERE prop_key=?")
+ .setString(1, "sonar.defaultGroup")
+ .execute().commit();
+ }
+
+}
@Test
public void verify_migration_count() {
- verifyMigrationCount(underTest, 20);
+ verifyMigrationCount(underTest, 21);
}
}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 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.v64;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class DeleteDefaultGroupSettingTest {
+
+ @Rule
+ public CoreDbTester db = CoreDbTester.createForSchema(DeleteDefaultGroupSettingTest.class, "initial.sql");
+
+ private DeleteDefaultGroupSetting underTest = new DeleteDefaultGroupSetting(db.database());
+
+ @Test
+ public void delete_setting() throws SQLException {
+ insertDefaultGroupProperty();
+
+ underTest.execute();
+
+ assertThat(db.countRowsOfTable("properties")).isZero();
+ }
+
+ @Test
+ public void does_not_fail_when_setting_does_not_exist() throws Exception {
+ underTest.execute();
+
+ assertThat(db.countRowsOfTable("properties")).isZero();
+ }
+
+ @Test
+ public void does_not_delete_other_setting() throws Exception {
+ insertDefaultGroupProperty();
+ insertProperty("sonar.prop", "a value");
+
+ underTest.execute();
+
+ assertThat(db.countRowsOfTable("properties")).isEqualTo(1);
+ }
+
+ @Test
+ public void migration_is_reentrant() throws Exception {
+ insertDefaultGroupProperty();
+
+ underTest.execute();
+ assertThat(db.countRowsOfTable("properties")).isZero();
+
+ underTest.execute();
+ assertThat(db.countRowsOfTable("properties")).isZero();
+ }
+
+ private void insertDefaultGroupProperty() {
+ insertProperty("sonar.defaultGroup", "123");
+ }
+
+ private void insertProperty(String key, String value) {
+ db.executeInsert(
+ "PROPERTIES",
+ "PROP_KEY", key,
+ "TEXT_VALUE", value,
+ "IS_EMPTY", "false",
+ "CREATED_AT", "1000");
+ }
+
+
+}
--- /dev/null
+CREATE TABLE "PROPERTIES" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "PROP_KEY" VARCHAR(512) NOT NULL,
+ "RESOURCE_ID" INTEGER,
+ "USER_ID" INTEGER,
+ "IS_EMPTY" BOOLEAN NOT NULL,
+ "TEXT_VALUE" VARCHAR(4000),
+ "CLOB_VALUE" CLOB(2147483647),
+ "CREATED_AT" BIGINT
+);
+CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES" ("PROP_KEY");