Skip to content

[Draft] Populate `finding_data` for `security_findings`

What does this MR do and why?

Related to Run migration to purge `security_scans` associa... (#409963 - closed).

Database review

The queries used by this change can be grouped as post-deployment ones and data migration ones.

Queries used in post-deployment migration

In the post-deployment migration, we are firing 3 queries to check if we need to schedule the background migration or not and to determine the lower, and upper bound of the migration.

Getting the first succeeded `security_scans` record
SELECT
    "security_scans".*
FROM
    "security_scans"
WHERE
    "security_scans"."status" = 1
ORDER BY
    "security_scans"."id" ASC
LIMIT 1
Getting the first `security_findings` record for the scans after the first succeeded `security_scans` record
SELECT
    "security_findings".*
FROM
    "security_findings"
WHERE (scan_id >= 1)
ORDER BY
    "security_findings"."id" ASC
LIMIT 1
Getting the first `security_findings` record without empty finding data
SELECT
    "security_findings".*
FROM
    "security_findings"
WHERE
    "security_findings"."finding_data" != '{}'
ORDER BY
    "security_findings"."id" ASC
LIMIT 1
Queries used in data migration

TBD

Edited by Mehmet Emin INAC

Merge request reports