Select statement to extract scan history

We upgraded SQ from 6.x (6.7.2) to 7.x (7.9.3 LTS). I need to extract scan history so we can decommission old SQ 6.x (DB and app servers). I figured we could run something like the following, but soon realized its a pseudo-code - no IDs like that are there:

select proj.name as ClassName, – Class Name for which violation has been found out
proj.long_name as LongName, – Long Class Name i.e. with package for which violation has been found out
rf.failure_level as ErrorLevel, – Error level of the violation
rf.message as Violation, – Cause of Violation
rf.line as LineNumber, – Line number of the class file
ru.name ViolationName, – Violation Description
ru.plugin_name PluginType – Plugin tool by which this error has been detected i.e. findbug, PMD, etc.
– ,ru.description – (if violation description is required we can add this column)
from projects proj
inner join snapshots snap on proj.id = snap.project_id
inner join rule_failures rf on rf.snapshot_id = snap.id
inner join rules ru on ru.id = rf.rule_id

What would the real select be like to accomplish the same?

Thanks!!!

Hello @danhersh,

We don’t provide assistance on database SQL queries, and we strongly NOT recommend our customers to directly tap in the database. This is often a recipe for big mistakes that may bring down your SonarQube.

The public interface we offer and support are the Web APIs that allows to do pretty much everything, including extracting the data that you are looking for.
I encourage you to have a look at the api/measures/search_history API that is the core of what you want to do.
The APIs are self documented in SonarQube by clicking on the “Web API” link in the footer of SonarQube pages.

Olivier

2 Likes