]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4137 fix size of MySQL index of PROPERTIES.PROP_KEY
authorSimon Brandhof <simon.brandhof@gmail.com>
Mon, 18 Feb 2013 09:53:45 +0000 (10:53 +0100)
committerSimon Brandhof <simon.brandhof@gmail.com>
Mon, 18 Feb 2013 12:14:13 +0000 (13:14 +0100)
sonar-server/src/main/webapp/WEB-INF/config/environment.rb
sonar-server/src/main/webapp/WEB-INF/db/migrate/059_create_properties.rb
sonar-server/src/main/webapp/WEB-INF/db/migrate/163_add_variation_columns.rb
sonar-server/src/main/webapp/WEB-INF/db/migrate/230_increase_qualifier_size.rb

index 5e0ea7a97035affd5d66ec3e274e65b9bc5df7c2..310506ac2bc8cc0b6e802ce8ab55b7490d8314e5 100644 (file)
@@ -87,6 +87,10 @@ end
 
 
 class ActiveRecord::Migration
+  def self.dialect
+    ActiveRecord::Base.configurations[ ENV['RAILS_ENV'] ]['dialect']
+  end
+
   def self.add_index(table_name, column_name, options = {})
     # ActiveRecord can generate index names longer than 30 characters, but that's
     # not supported by Oracle, the "Enterprise" database.
index d35ad09077d3a4aadca4d983cc4c9b503997625f..c39d02d7d03a5bc198c83f6719bc9207cc425d5a 100644 (file)
@@ -26,7 +26,15 @@ class CreateProperties < ActiveRecord::Migration
            t.column :text_value, :text, :null => true
       t.column :user_id, :integer, :null => true
     end
-    add_index :properties, :prop_key, :name => 'properties_key'
+
+    if dialect()=='mysql'
+      # Index of varchar column is limited to 767 bytes on mysql (<= 255 UTF-8 characters)
+      # See http://jira.codehaus.org/browse/SONAR-4137 and
+      # http://dev.mysql.com/doc/refman/5.6/en/innodb-restrictions.html
+      add_index :properties, :prop_key, :name => 'properties_key', :length => 255
+    else
+      add_index :properties, :prop_key, :name => 'properties_key'
+    end
   end
 
 end
index 62735d89269a136c01582004ba6a5dd19bc33648..50c33b9fb665b03adb34887df88388f43b9dc4d2 100644 (file)
@@ -33,10 +33,7 @@ class AddVariationColumns < ActiveRecord::Migration
     ProjectMeasure.reset_column_information
     Snapshot.reset_column_information
 
-    dialect = ActiveRecord::Base.configurations[ ENV['RAILS_ENV'] ]["dialect"]
-    say "Detected dialect: #{dialect}"
-
-    case dialect
+    case dialect()
     when "sqlserver"
       upgrade_sqlserver()
     when "oracle"
index 0e99ba23ad6c60d4a2329a131f1f343ec695ebd7..4189463ba5f550d88dd10e690ff5be2fc0cd25a9 100644 (file)
 class IncreaseQualifierSize < ActiveRecord::Migration
 
   def self.up
-    dialect = ActiveRecord::Base.configurations[ ENV['RAILS_ENV'] ]["dialect"]
-
-    if dialect == 'sqlserver'
+    if dialect()=='sqlserver'
       remove_index :snapshots, :name => 'snapshots_qualifier'
     end
 
     change_column('snapshots', 'qualifier', :string, :limit => 10, :null => true)
     change_column('projects', 'qualifier', :string, :limit => 10, :null => true)
 
-    if dialect == 'sqlserver'
+    if dialect()=='sqlserver'
       add_index :snapshots, :qualifier, :name => 'snapshots_qualifier'
     end
   end