From: Simon Brandhof Date: Mon, 22 Oct 2012 09:02:23 +0000 (+0200) Subject: SONAR-3887 fix compatibility with MySQL X-Git-Tag: 3.4~460 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=84b672373f32aafcd8b79769722100e6e4ad0683;p=sonarqube.git SONAR-3887 fix compatibility with MySQL --- 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