]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7212 Remove migration to remove default assignee properties on removed users
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 4 May 2016 07:11:07 +0000 (09:11 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 4 May 2016 08:25:18 +0000 (10:25 +0200)
Remove this migration because in Oracle, PROPERTIES.TEXT_VALUE is a clob, so it's not possible to do a JOIN on this column

server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1200_remove_default_assignee_properties_on_disabled_users.rb [deleted file]
sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java
sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java
sonar-db/src/main/java/org/sonar/db/version/v56/RemoveDefaultAssigneePropertiesOnDisabledUsers.java [deleted file]
sonar-db/src/main/java/org/sonar/db/version/v56/package-info.java [deleted file]
sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql
sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java
sonar-db/src/test/java/org/sonar/db/version/v56/RemoveDefaultAssigneePropertiesOnDisabledUsersTest.java [deleted file]
sonar-db/src/test/resources/org/sonar/db/version/v56/RemoveDefaultAssigneePropertiesOnDisabledUsersTest/schema.sql [deleted file]

diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1200_remove_default_assignee_properties_on_disabled_users.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1200_remove_default_assignee_properties_on_disabled_users.rb
deleted file mode 100644 (file)
index 1735644..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# SonarQube, open source software quality management tool.
-# Copyright (C) 2008-2014 SonarSource
-# mailto:contact AT sonarsource DOT com
-#
-# SonarQube 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.
-#
-# SonarQube 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.
-#
-
-#
-# SonarQube 5.6
-# SONAR-7212
-#
-class RemoveDefaultAssigneePropertiesOnDisabledUsers < ActiveRecord::Migration
-
-  def self.up
-    execute_java_migration('org.sonar.db.version.v56.RemoveDefaultAssigneePropertiesOnDisabledUsers')
-  end
-
-end
index 64d794990164be64a1c649f7a559c24dd6024a9b..8f51cc19382a514fe0f9c8d3bcde01229d3c5333 100644 (file)
@@ -29,7 +29,7 @@ import org.sonar.db.MyBatis;
 
 public class DatabaseVersion {
 
-  public static final int LAST_VERSION = 1200;
+  public static final int LAST_VERSION = 1125;
 
   /**
    * The minimum supported version which can be upgraded. Lower
index cd2a0d76dd5ae3fd8dbb88f13ff4901012c8dce3..831333de097423eb4442e91056447208b8ddf71a 100644 (file)
@@ -82,7 +82,6 @@ import org.sonar.db.version.v55.FeedActiveRulesLongDateColumns;
 import org.sonar.db.version.v55.FeedIssueTypes;
 import org.sonar.db.version.v55.FeedRulesLongDateColumns;
 import org.sonar.db.version.v55.FeedRulesTypes;
-import org.sonar.db.version.v56.RemoveDefaultAssigneePropertiesOnDisabledUsers;
 
 public class MigrationStepModule extends Module {
   @Override
@@ -162,10 +161,6 @@ public class MigrationStepModule extends Module {
       FeedRulesTypes.class,
       DeleteMeasuresWithRuleId.class,
       DeleteManualIssues.class,
-      DeleteManualRules.class,
-
-      // 5.6
-      RemoveDefaultAssigneePropertiesOnDisabledUsers.class
-    );
+      DeleteManualRules.class);
   }
 }
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v56/RemoveDefaultAssigneePropertiesOnDisabledUsers.java b/sonar-db/src/main/java/org/sonar/db/version/v56/RemoveDefaultAssigneePropertiesOnDisabledUsers.java
deleted file mode 100644 (file)
index b3942a6..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact 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.db.version.v56;
-
-import java.sql.SQLException;
-import org.sonar.db.Database;
-import org.sonar.db.version.BaseDataChange;
-import org.sonar.db.version.MassUpdate;
-import org.sonar.db.version.Select;
-import org.sonar.db.version.SqlStatement;
-
-/**
- * Remove properties "sonar.issues.defaultAssigneeLogin" when values are on removed users
- */
-public class RemoveDefaultAssigneePropertiesOnDisabledUsers extends BaseDataChange {
-
-  private static final String DEFAULT_ISSUE_ASSIGNEE_PROP = "sonar.issues.defaultAssigneeLogin";
-
-  public RemoveDefaultAssigneePropertiesOnDisabledUsers(Database db) {
-    super(db);
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    MassUpdate massUpdate = context.prepareMassUpdate();
-    massUpdate.select("SELECT p.id FROM properties p " +
-      "INNER JOIN users u ON u.login=p.text_value AND u.active=? " +
-      "WHERE p.prop_key=?")
-      .setBoolean(1, false)
-      .setString(2, DEFAULT_ISSUE_ASSIGNEE_PROP);
-    massUpdate.update("DELETE FROM properties WHERE id=?");
-    massUpdate.rowPluralName("default assignee properties on removed users");
-    massUpdate.execute(new MigrationHandler());
-  }
-
-  private static class MigrationHandler implements MassUpdate.Handler {
-
-    @Override
-    public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
-      Long id = row.getNullableLong(1);
-      update.setLong(1, id);
-      return true;
-    }
-  }
-
-}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v56/package-info.java b/sonar-db/src/main/java/org/sonar/db/version/v56/package-info.java
deleted file mode 100644 (file)
index c3a55a0..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact 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.db.version.v56;
-
-import javax.annotation.ParametersAreNonnullByDefault;
-
index c6dccde162f5cba4ad12dacf52c5030a9c9c1606..72e8889de26b5e8c61c9a31d351f05ecd11b5fcc 100644 (file)
@@ -403,7 +403,6 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1122');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1123');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1124');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1125');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1200');
 
 INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, EXTERNAL_IDENTITY, EXTERNAL_IDENTITY_PROVIDER, USER_LOCAL, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'admin', 'sonarqube', true, 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '1418215735482', '1418215735482', null, null);
 ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2;
index 91bda96d3de5462b16882e5d320df004b6661097..20c4b0d35370fb64aba1c0faf0dc26619328410b 100644 (file)
@@ -29,6 +29,6 @@ public class MigrationStepModuleTest {
   public void verify_count_of_added_MigrationStep_types() {
     ComponentContainer container = new ComponentContainer();
     new MigrationStepModule().configure(container);
-    assertThat(container.size()).isEqualTo(65);
+    assertThat(container.size()).isEqualTo(64);
   }
 }
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v56/RemoveDefaultAssigneePropertiesOnDisabledUsersTest.java b/sonar-db/src/test/java/org/sonar/db/version/v56/RemoveDefaultAssigneePropertiesOnDisabledUsersTest.java
deleted file mode 100644 (file)
index b200b6c..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact 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.db.version.v56;
-
-import com.google.common.collect.ImmutableMap;
-import java.util.List;
-import java.util.Map;
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
-import org.sonar.db.version.MigrationStep;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class RemoveDefaultAssigneePropertiesOnDisabledUsersTest {
-
-  @Rule
-  public DbTester db = DbTester.createForSchema(System2.INSTANCE, RemoveDefaultAssigneePropertiesOnDisabledUsersTest.class, "schema.sql");
-
-  private MigrationStep migration = new RemoveDefaultAssigneePropertiesOnDisabledUsers(db.database());;
-
-  @Test
-  public void delete_properties() throws Exception {
-    insertUser("user1", false);
-    insertUser("user2", true);
-
-    insertProperty("sonar.issues.defaultAssigneeLogin", "user1", 10L);
-    insertProperty("sonar.issues.defaultAssigneeLogin", "user1", 11L);
-    insertProperty("sonar.other.property", "user1", 11L);
-    insertProperty("sonar.issues.defaultAssigneeLogin", "user2", 13L);
-
-    migration.execute();
-
-    List<Map<String, Object>> rows = db.select("select prop_key, text_value from properties");
-    assertThat(rows).containsOnly(
-      ImmutableMap.<String, Object>of("PROP_KEY", "sonar.issues.defaultAssigneeLogin","TEXT_VALUE", "user2"),
-      ImmutableMap.<String, Object>of("PROP_KEY", "sonar.other.property","TEXT_VALUE", "user1")
-    );
-  }
-
-  private void insertUser(String login, boolean active) {
-    db.executeInsert("users", ImmutableMap.of(
-      "LOGIN", login,
-      "ACTIVE", Boolean.toString(active)
-    ));
-  }
-
-  private void insertProperty(String key, String value, long componentId) {
-    db.executeInsert("properties", ImmutableMap.of(
-      "PROP_KEY", key,
-      "RESOURCE_ID", Long.toString(componentId),
-      "TEXT_VALUE", value
-    ));
-  }
-
-}
diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v56/RemoveDefaultAssigneePropertiesOnDisabledUsersTest/schema.sql b/sonar-db/src/test/resources/org/sonar/db/version/v56/RemoveDefaultAssigneePropertiesOnDisabledUsersTest/schema.sql
deleted file mode 100644 (file)
index f8c90e9..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-CREATE TABLE "USERS" (
-  "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
-  "LOGIN" VARCHAR(255),
-  "NAME" VARCHAR(200),
-  "EMAIL" VARCHAR(100),
-  "CRYPTED_PASSWORD" VARCHAR(40),
-  "SALT" VARCHAR(40),
-  "REMEMBER_TOKEN" VARCHAR(500),
-  "REMEMBER_TOKEN_EXPIRES_AT" TIMESTAMP,
-  "ACTIVE" BOOLEAN DEFAULT TRUE,
-  "SCM_ACCOUNTS" VARCHAR(4000),
-  "EXTERNAL_IDENTITY" VARCHAR(255),
-  "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100),
-  "USER_LOCAL" BOOLEAN,
-  "CREATED_AT" BIGINT,
-  "UPDATED_AT" BIGINT
-);
-
-CREATE TABLE "PROPERTIES" (
-  "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
-  "PROP_KEY" VARCHAR(512),
-  "RESOURCE_ID" INTEGER,
-  "TEXT_VALUE" CLOB(2147483647),
-  "USER_ID" INTEGER
-);