]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5405 Do not ignore errors on creation of db index
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Sun, 22 Jun 2014 21:49:46 +0000 (23:49 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 23 Jun 2014 12:58:08 +0000 (14:58 +0200)
12 files changed:
sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java
sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql
sonar-server/src/main/webapp/WEB-INF/db/migrate/351_add_unique_index_to_authors.rb
sonar-server/src/main/webapp/WEB-INF/db/migrate/387_create_snapshot_data.rb
sonar-server/src/main/webapp/WEB-INF/db/migrate/397_add_index_to_users_login.rb
sonar-server/src/main/webapp/WEB-INF/db/migrate/404_add_index_to_snapshots_root_project_id.rb
sonar-server/src/main/webapp/WEB-INF/db/migrate/405_add_index_to_group_roles_role.rb
sonar-server/src/main/webapp/WEB-INF/db/migrate/419_add_index_to_rules_plugin_rule_key_and_plugin_name.rb
sonar-server/src/main/webapp/WEB-INF/db/migrate/433_add_index_to_characteristics_enabled.rb
sonar-server/src/main/webapp/WEB-INF/db/migrate/532_increase_size_of_user_login.rb
sonar-server/src/main/webapp/WEB-INF/db/migrate/540_create_activities_table.rb
sonar-server/src/main/webapp/WEB-INF/db/migrate/554_add_missing_user_unique_index.rb [new file with mode: 0644]

index e873c66cd809ca8363d11d792958e5573d2af407..bfc0a38e0959893038905e41860f9e5ab1dc34fa 100644 (file)
@@ -33,7 +33,7 @@ import java.util.List;
  */
 public class DatabaseVersion implements BatchComponent, ServerComponent {
 
-  public static final int LAST_VERSION = 553;
+  public static final int LAST_VERSION = 554;
 
   public static enum Status {
     UP_TO_DATE, REQUIRES_UPGRADE, REQUIRES_DOWNGRADE, FRESH_INSTALL
index 0485e75a9762a48477d690f4349b8b13db3b6599..0acc327fe71b3de2bc97e436c2c488bd4167d155 100644 (file)
@@ -246,6 +246,7 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('549');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('551');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('552');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('553');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('554');
 
 INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '2011-09-26 22:27:48.0', '2011-09-26 22:27:48.0', null, null);
 ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2;
index cc998ef24f0895532640a1e61086b398e582d219..9e98bb2fbdec62771fbd6035f9d0da68db220e2f 100644 (file)
@@ -28,11 +28,7 @@ class AddUniqueIndexToAuthors < ActiveRecord::Migration
 
   def self.up
     delete_duplicated_authors
-    begin
-      add_index :authors, :login, :unique => true, :name => 'uniq_author_logins'
-    rescue
-      # Ignore, already exists
-    end
+    add_index :authors, :login, :unique => true, :name => 'uniq_author_logins'
   end
 
   private
index cb297818210163d4552e62aea50cbdd848fd81c6..f97f16c8ae6ff3e31b42ce483488592d016710ed 100644 (file)
@@ -33,11 +33,8 @@ class CreateSnapshotData < ActiveRecord::Migration
       t.timestamps
     end
 
-    begin
-      add_index :snapshot_data, :snapshot_id, :name => 'snapshot_data_snapshot_id'
-    rescue
-      #ignore already existing index
-    end
+    add_index :snapshot_data, :snapshot_id, :name => 'snapshot_data_snapshot_id'
+
   end
 
 
index 5cd0e5864513d0aae27bbdf99df8ca4f1de44657..d750fc3487eccebcc09eb134f04ceb013dd75991 100644 (file)
 class AddIndexToUsersLogin < ActiveRecord::Migration
 
   def self.up
-    begin
-      add_index :users, :login, :name => 'users_login', :unique => true
-    rescue
-      # already exists
-    end
-
+    add_index :users, :login, :name => 'users_login', :unique => true
   end
 
 end
index e0ae3c3b3f2913e53c3285545ab955b612c819a2..273ad93a642f343313e9f0248bf9b4f1340df69a 100644 (file)
 class AddIndexToSnapshotsRootProjectId < ActiveRecord::Migration
 
   def self.up
-    begin
-      add_index :snapshots, :root_project_id, :name => 'snapshots_root_project_id'
-    rescue
-      # already exists
-    end
-
+    add_index :snapshots, :root_project_id, :name => 'snapshots_root_project_id'
   end
 
 end
index 2d74d49659ee434c00376c66c869ebfe94055cd2..33dce069ae2710259b6ffd338356e5187ffabe0c 100644 (file)
 class AddIndexToGroupRolesRole < ActiveRecord::Migration
 
   def self.up
-    begin
-      add_index :group_roles, :role, :name => 'group_roles_role'
-    rescue
-      # already exists
-    end
-
+    add_index :group_roles, :role, :name => 'group_roles_role'
   end
 
 end
index 09e6452751b6bdb4402a780b08c8e05a5d0b28df..5146886b431b4dbed1f5a46e055178271a281d75 100644 (file)
 class AddIndexToRulesPluginRuleKeyAndPluginName < ActiveRecord::Migration
 
   def self.up
-    begin
-      add_index :rules, [:plugin_rule_key, :plugin_name], :unique => true, :name => 'rules_plugin_key_and_name'
-    rescue
-      # already exists
-    end
+    add_index :rules, [:plugin_rule_key, :plugin_name], :unique => true, :name => 'rules_plugin_key_and_name'
   end
 
 end
index 2f228f3e2ac9180b64337d1dd1f3c17118b9124f..ebeb3babbf8ea22d0d5c5f0d907a2f6c6559853c 100644 (file)
 class AddIndexToCharacteristicsEnabled < ActiveRecord::Migration
 
   def self.up
-    begin
-      add_index :characteristics, :enabled, :name => 'characteristics_enabled'
-    rescue
-      # already exists
-    end
+    add_index :characteristics, :enabled, :name => 'characteristics_enabled'
   end
 end
 
index 393c9bf62f1591aad114ab0d282b6f6712a53bcd..bf89707c38a3f7387c27fdfab9f1b8a7f7555d57 100644 (file)
@@ -45,8 +45,8 @@ class IncreaseSizeOfUserLogin < ActiveRecord::Migration
     change_column :users, :login, :string, :limit => 255, :unique => true
 
     if dialect()=='sqlserver'
-      add_index :users, :login, :name => 'users_login'
-      add_index :authors, :login, :unique => true, :name => 'uniq_author_logins'
+      add_index :users, :login, :name => 'users_login', :unique => true
+      add_index :authors, :login, :name => 'uniq_author_logins', :unique => true
       add_index :issue_filter_favourites, :user_login, :name => 'issue_filter_favs_user'
       add_index :issues,  :assignee, :name => 'issues_assignee'
     end
index 207b371b689e2708f446c6f2744e3bd55d8b0e1b..590dbac61b1ee352fbf9e8ffdb00000eb7816d78 100644 (file)
@@ -33,6 +33,6 @@ class CreateActivitiesTable < ActiveRecord::Migration
       t.column 'log_message', :string, :limit => 4000
       t.column 'log_key', :string
     end
-    add_index 'activities', :log_key, :unique => true, :name => 'activities_log_key'
+    add_index 'activities', :log_key, :name => 'activities_log_key', :unique => true
   end
 end
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/554_add_missing_user_unique_index.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/554_add_missing_user_unique_index.rb
new file mode 100644 (file)
index 0000000..614cf41
--- /dev/null
@@ -0,0 +1,33 @@
+#
+# 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 4.4
+# See SONAR-5405
+#
+class AddMissingUserUniqueIndex < ActiveRecord::Migration
+
+  def self.up
+    unless index_exists?(:users, :login, nil)
+      add_index :users, :login, :name => 'users_login', :unique => true
+    end
+  end
+
+end