aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2012-10-22 11:02:23 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2012-10-22 11:02:23 +0200
commit84b672373f32aafcd8b79769722100e6e4ad0683 (patch)
tree8f6ef6cc1c978656ed248a6f45339c3f173b56f7
parent0aaf2941ee812b63c7f84b357586ecfba9853b15 (diff)
downloadsonarqube-84b672373f32aafcd8b79769722100e6e4ad0683.tar.gz
sonarqube-84b672373f32aafcd8b79769722100e6e4ad0683.zip
SONAR-3887 fix compatibility with MySQL
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl6
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/350_create_semaphores.rb9
2 files changed, 12 insertions, 3 deletions
diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl b/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl
index 152c74226cb..55d37119219 100644
--- a/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl
+++ b/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl
@@ -614,6 +614,8 @@ CREATE INDEX "INDEX_RULE_NOTES_ON_ACTIVE_RULE_ID" ON "RULE_NOTES" ("RULE_ID");
CREATE INDEX "REVIEWS_RID" ON "REVIEWS" ("RESOURCE_ID");
-CREATE UNIQUE INDEX "uniq_semaphore_names" ON "SEMAPHORES" ("CHECKSUM");
+CREATE UNIQUE INDEX "UNIQ_SEMAPHORE_CHECKSUMS" ON "SEMAPHORES" ("CHECKSUM");
-CREATE UNIQUE INDEX "uniq_author_logins" ON "AUTHORS" ("LOGIN");
+CREATE INDEX "SEMAPHORE_NAMES" ON "SEMAPHORES" ("NAME");
+
+CREATE UNIQUE INDEX "UNIQ_AUTHOR_LOGINS" ON "AUTHORS" ("LOGIN");
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/350_create_semaphores.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/350_create_semaphores.rb
index fefcabc794c..ce710ccc8d9 100644
--- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/350_create_semaphores.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/350_create_semaphores.rb
@@ -24,13 +24,20 @@
class CreateSemaphores < ActiveRecord::Migration
def self.up
+
+ # MySQL does not manage unique indexes on columns with more than 767 characters
+ # A letter can be encoded with up to 3 characters (it depends on the db charset),
+ # so unique indexes are allowed only on columns with less than 767/3=255 characters.
+ # For this reason the checksum of semaphore name is computed and declared as unique.
+ # There are no constraints on the semaphore name itself.
create_table :semaphores do |t|
t.string :name, :limit => 4000, :null => false
t.string :checksum, :limit => 200, :null => false
t.datetime :locked_at
t.timestamps
end
- add_index :semaphores, :name, :unique => true, :name => 'uniq_semaphore_names'
+ add_index :semaphores, :checksum, :unique => true, :name => 'uniq_semaphore_checksums'
+ add_index :semaphores, :name, :name => 'semaphore_names'
end
end