SonarQube升级3.5.1到5.0在MySQL数据库迁移时失败

时间:2015-02-16 17:07:32

标签: mysql sonarqube

我的当前系统设置如下:

  • SonarQube版本:3.5.1
  • MySQL版本:5.6.11
  • 操作系统:Windows 2008 R2

我正在尝试根据SonarQube upgrade guide将SonarQube从3.5.1版升级到5.0版。

当我从UI点击“升级”时,它会在我粘贴在下面的sonar.log文件中抛出一个错误。错误显示表“snapshot_data”已存在。我已经验证并且表存在于数据库中。

我知道为什么声纳正在检查已经存在的表吗?

2015.02.16 16:53:58 INFO  web[DbMigration]  ==  CreateSnapshotData: migrating =============================================
2015.02.16 16:53:58 INFO  web[DbMigration]  -- create_table(:snapshot_data, {})
2015.02.16 16:53:58 ERROR web[o.s.s.ui.JRubyFacade]  Fail to upgrade database
An error has occurred, all later migrations canceled:

ActiveRecord::JDBCError: Table 'snapshot_data' already exists: CREATE TABLE `snapshot_data` (`id` int(11) auto_increment PRIMARY KEY, `snapshot_id` integer, `resource_id` integer, `snapshot_data` longtext, `data_type` varchar(50), `created_at` datetime, `updated_at` datetime) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin
                D:/sonarqube-5.0/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract_adapter.rb:227:in `log'
                D:/sonarqube-5.0/web/WEB-INF/gems/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/adapter.rb:183:in `execute'
                D:/sonarqube-5.0/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/schema_statements.rb:109:in `create_table'
                D:/sonarqube-5.0/web/WEB-INF/gems/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/mysql/adapter.rb:252:in `create_table'
                org/jruby/RubyKernel.java:2231:in `send'
                D:/sonarqube-5.0/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:352:in `method_missing'
                D:/sonarqube-5.0/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:328:in `say_with_time'
                jar:file:/D:/sonarqube-5.0/lib/server/jruby-complete-1.7.9.jar!/META-INF/jruby.home/lib/ruby/1.8/benchmark.rb:293:in `measure'
                D:/sonarqube-5.0/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:328:in `say_with_time'
                D:/sonarqube-5.0/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:348:in `method_missing'
                D:/sonarqube-5.0/web/WEB-INF/config/environment.rb:176:in `create_table'
                D:/sonarqube-5.0/web/WEB-INF/config/../lib/../db/migrate/387_create_snapshot_data.rb:28:in `up'
                org/jruby/RubyKernel.java:2223:in `send'
                D:/sonarqube-5.0/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:282:in `migrate'
                jar:file:/D:/sonarqube-5.0/lib/server/jruby-complete-1.7.9.jar!/META-INF/jruby.home/lib/ruby/1.8/benchmark.rb:293:in `measure'
                D:/sonarqube-5.0/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:282:in `migrate'
                org/jruby/RubyKernel.java:2227:in `send'
                D:1:in `migrate'
                D:/sonarqube-5.0/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'
                D:/sonarqube-5.0/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:576:in `ddl_transaction'
                D:/sonarqube-5.0/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:490:in `migrate'
                org/jruby/RubyArray.java:1613:in `each'
                D:/sonarqube-5.0/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:477:in `migrate'
                D:/sonarqube-5.0/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:401:in `up'
                D:/sonarqube-5.0/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:383:in `migrate'
                D:/sonarqube-5.0/web/WEB-INF/config/../lib/database_version.rb:62:in `upgrade_and_start'
                D:/sonarqube-5.0/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'

1 个答案:

答案 0 :(得分:1)

snapshot_data表是在the migration script #387期间创建的,属于SonarQube 3.6。

如果您收到此错误,这可能意味着您之前已完成失败的迁移,并且您尝试再次重播它。所以我建议您恢复之前SonarQube 3.5.1状态的数据库(假设您有备份),并重放完整的迁移。

相关问题