【发布时间】:2014-09-02 14:14:53
【问题描述】:
尝试从 4.3.2 升级到 Sonar 4.4 时,数据库迁移失败并显示以下内容
以前有人见过吗? 快速查看 jira 问题,但没有找到任何相关内容。
使用 MS SQLServer 2008
...
2014.08.29 11:58:12 INFO [DbMigration]
2014.08.29 11:58:12 INFO [DbMigration] == InverseRuleKeyIndex: 迁移 ================================= ===========
2014.08.29 11:58:12 信息 [DbMigration] -- remove_index(:rules, {:name=>"rules_plugin_key_and_name"})
2014.08.29 11:58:12 INFO [DbMigration] -- 删除重复的规则
2014.08.29 11:58:12 信息 [DbMigration] -> 0.0620s
2014.08.29 11:58:12 INFO [DbMigration] -- add_index(:rules, [:plugin_name, :plugin_rule_key], {:unique=>true, :name=>"rules_repo_key"})
2014.08.29 11:58:12 错误 [o.s.s.ui.JRubyFacade] 升级数据库失败
发生错误,此迁移和所有后续迁移均已取消:
ActiveRecord::JDBCError: The CREATE UNIQUE INDEX statement terminated because a duplicate key was found for the object name 'sonar.rules' and the index name 'rules_repo_key'. The duplicate key value is (grvy, org.codenarc.rule.basic.HardCodedWindowsRootDirectoryRule).: CREATE UNIQUE INDEX [rules_repo_key] ON [rules] ([plugin_name], [plugin_rule_key])
E:/Server/sonarqube-4.4/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract_adapter.rb:227:in `log'
E:/Server/sonarqube-4.4/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract_adapter.rb:212:in `log'
E:/Server/sonarqube-4.4/web/WEB-INF/gems/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/adapter.rb:183:in `execute'
E:/Server/sonarqube-4.4/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/schema_statements.rb:292:in `add_index'
org/jruby/RubyKernel.java:2235:in `send'
E:/Server/sonarqube-4.4/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:352:in `method_missing'
E:/Server/sonarqube-4.4/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:328:in `say_with_time'
jar:file:/E:/Server/sonarqube-4.4/web/WEB-INF/lib/jruby-complete-1.7.9.jar!/META-INF/jruby.home/lib/ruby/1.8/benchmark.rb:293:in `measure'
E:/Server/sonarqube-4.4/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:328:in `say_with_time'
E:/Server/sonarqube-4.4/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:348:in `method_missing'
E:/Server/sonarqube-4.4/web/WEB-INF/config/environment.rb:124:in `add_index'
E:/Server/sonarqube-4.4/web/WEB-INF/config/../lib/../db/migrate/546_inverse_rule_key_index.rb:66:in `up'
org/jruby/RubyKernel.java:2223:in `send'
E:/Server/sonarqube-4.4/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:282:in `migrate'
jar:file:/E:/Server/sonarqube-4.4/web/WEB-INF/lib/jruby-complete-1.7.9.jar!/META-INF/jruby.home/lib/ruby/1.8/benchmark.rb:293:in `measure'
E:/Server/sonarqube-4.4/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:282:in `migrate'
org/jruby/RubyKernel.java:2227:in `send'
E:1:in `migrate'
E:/Server/sonarqube-4.4/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:491:in `migrate'
org/jruby/RubyProc.java:290:in `call'
org/jruby/RubyProc.java:224:in `call'
E:/Server/sonarqube-4.4/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:565:in `ddl_transaction'
E:/Server/sonarqube-4.4/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in `transaction'
E:/Server/sonarqube-4.4/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/transactions.rb:182:in `transaction'
E:/Server/sonarqube-4.4/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:565:in `ddl_transaction'
E:/Server/sonarqube-4.4/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:490:in `migrate'
org/jruby/RubyArray.java:1613:in `each'
E:/Server/sonarqube-4.4/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:477:in `migrate'
E:/Server/sonarqube-4.4/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:401:in `up'
E:/Server/sonarqube-4.4/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:383:in `migrate'
E:/Server/sonarqube-4.4/web/WEB-INF/config/../lib/database_version.rb:62:in `upgrade_and_start'
E:/Server/sonarqube-4.4/web/WEB-INF/app/models/database_migration_manager.rb:109:in `start_migration'
org/jruby/RubyProc.java:290:in `call'
org/jruby/RubyProc.java:228:in `call'
...
【问题讨论】: