Skip to content

Commit d760fd4

Browse files
oheger-boschsschuberth
authored andcommitted
fix(dao): Add DELETE CASCADE constraint for path includes table
This constraint was missed when creating the table. It is required for deleting ORT runs, which will cause foreign key violations otherwise. Signed-off-by: Oliver Heger <oliver.heger@bosch.com>
1 parent 583421f commit d760fd4

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-- This migration script modifies the foreign key constraints of the repository_configurations_path_includes table
2+
-- to add an ON DELETE CASCADE clause. This was missed when the table was created; therefore, ORT runs with path
3+
-- includes cannot be deleted.
4+
5+
ALTER TABLE repository_configurations_path_includes
6+
DROP CONSTRAINT fk_repository_configurations_path_includes_config_id,
7+
ADD CONSTRAINT fk_repository_configurations_path_includes_config_id
8+
FOREIGN KEY (repository_configuration_id) REFERENCES repository_configurations (id) ON DELETE CASCADE;

services/ort-run/src/test/kotlin/OrtRunServiceTest.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,14 @@ class OrtRunServiceTest : WordSpec({
267267

268268
"deleteOrtRun" should {
269269
"delete an ORT run" {
270-
val ortRunId = createOrtRun()
270+
val ortRunId = createOrtRun(
271+
db = db,
272+
vcsInfo = null,
273+
processedVcsInfo = null,
274+
nestedVcsInfo1 = createVcsInfo("https://example.com/repo1.git"),
275+
nestedVcsInfo2 = createVcsInfo("https://example.com/repo2.git"),
276+
fixtures
277+
).id
271278
val jobId = createReporterJob(ortRunId)
272279

273280
val mockReportStorageService = mockk<ReportStorageService> {

0 commit comments

Comments
 (0)