如何更改现有声纳快照的日期?

时间:2013-07-08 14:01:24

标签: sonarqube

我最近使用sonar.projectDate属性构建历史记录。但是,我对日期犯了一个错误并将其设置为未来(2913-05-29)。现在我不能对项目进行任何新的分析。由于这是最新的分析,我没有历史记录页面上的“删除快照”按钮。

所以,我想只是改变分析的日期,因为它是有效的并且是最新的。我已经对下面的表进行了更改,这些表似乎有“坏”日期:快照,事件,问题。

update snapshots set 
  created_at = to_timestamp('05/29/2013', 'MM/dd/yyyy'),
  period2_date = to_timestamp('05/24/2013', 'MM/dd/yyyy'),
  period3_date = to_timestamp('04/29/2013', 'MM/dd/yyyy')
where id = ${snapshotId};

update snapshots set 
  created_at = to_timestamp('05/29/2013', 'MM/dd/yyyy')
where root_snapshot_id = ${snapshotId};

update events set 
  event_date = to_timestamp('05/29/2013', 'MM/dd/yyyy')
where snapshot_id = ${snapshotId};

严格来说,我认为我不需要这样做,因为它与快照无关,但我认为这有助于排列问题。

update issues set 
  issue_creation_date = to_timestamp('05/29/2013', 'MM/dd/yyyy'),
  issue_update_date = to_timestamp('05/29/2013', 'MM/dd/yyyy'),
  created_at = to_timestamp('05/29/2013', 'MM/dd/yyyy'),
  updated_at = to_timestamp('05/29/2013', 'MM/dd/yyyy')
where root_component_id = ${projectId}
  and created_at > to_timestamp('01/01/2014', 'MM/dd/yyyy');

更新快照表后,GUI会加载正确的信息,但我仍无法开始新的分析。

[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.0:sonar (default-cli) on project rc-parent: 
Can not execute Sonar: 'sonar.projectDate' property cannot be older than the date of the last known quality snapshot on this project. Value: '2013-06-29'. Latest quality snapshot: '2913-05-29'. This property may only be used to rebuild the past in a chronological order. -> [Help 1]

我现在正在运行Sonar 3.6,但在“糟糕”分析运行期间运行了3.4.1。

我正在寻找选择。改变日期的正确方法或手动分析删除程序。

2 个答案:

答案 0 :(得分:2)

对于MySQL DB,执行:

  1. 获取项目ID

    select * from projects where name='foo';

  2. 获取项目的当前快照:

    select * from events where resource_id = ${project_id};

  3. 首先,检查build_date是否具有有效的日期时间

    select * from snapshots where id=${snapshot_id};

    如果是,(对事件也一样)运行:

    update snapshots set created_at=build_date where id=${snapshot_id};

    update events set event_date=created_date where snapshot_id=${snapshot_id};

    如果不是,请运行:

    update snapshots set created_at=CURDATE() where id=${snapshot_id};

    update events set event_date=CURDATE() where snapshot_id=${snapshot_id};

答案 1 :(得分:1)

最终,对snapshots表的两次sql更新就行了起来。它不优雅,但我能够开始新的声纳分析并正确记录所有内容。