Skip to content

Commit 88e46bc

Browse files
committed
Add scripts to delete DC and DCG rows and associated rows in other tables
1 parent 7543303 commit 88e46bc

File tree

2 files changed

+103
-0
lines changed

2 files changed

+103
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
-- This is a script to delete a given DataCollectionGroup (by
2+
-- dataCollectionGroupId) and all associated rows in other tables except
3+
-- DataCollection.
4+
-- To delete DataCollections, run the DataCollection_delete.sql script first
5+
-- before you run this.
6+
-- Change the value of @dcgId and @sessionId to the values of
7+
-- dataCollectionGroupId and sessionId you would like to delete.
8+
-- Disclaimer:
9+
-- This script is not extensively tested.
10+
-- Run this at your own risk and beware of cascading deletes.
11+
12+
SET @dcgId := 1000;
13+
SET @sessionId = 999;
14+
15+
DELETE XrayCentringResult
16+
FROM XrayCentringResult
17+
JOIN XrayCentring
18+
WHERE XrayCentring.xrayCentringId = XrayCentringResult.xrayCentringId AND
19+
XrayCentring.dataCollectionGroupId = @dcgId;
20+
21+
DELETE
22+
FROM XrayCentring
23+
WHERE dataCollectionGroupId = @dcgId;
24+
25+
DELETE
26+
FROM DataCollectionGroup
27+
WHERE dataCollectionGroupId = @dcgId;
28+
29+
DELETE RobotAction
30+
FROM RobotAction
31+
JOIN DataCollectionGroup
32+
WHERE RobotAction.blsessionId = @sessionId AND
33+
DataCollectionGroup.blSampleId = RobotAction.blSampleId AND
34+
DataCollectionGroup.dataCollectionGroupId = @dcgId;
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
-- This is a script to delete a given DataCollection (by dataCollectionId) and
2+
-- all associated rows in other tables.
3+
-- Change the value of @dcId to the dataCollectionId you would like to delete.
4+
-- Disclaimer:
5+
-- This script is not extensively tested. It also currently will leave behind
6+
-- some orphaned rows.
7+
-- Run this at your own risk and beware of cascading deletes.
8+
9+
SET @dcId := 1000;
10+
11+
DELETE
12+
FROM ImageQualityIndicators
13+
WHERE dataCollectionId = @dcId;
14+
15+
DELETE ProcessingJobParameter
16+
FROM ProcessingJobParameter
17+
JOIN ProcessingJob
18+
WHERE ProcessingJob.processingJobId = ProcessingJobParameter.processingJobId AND
19+
ProcessingJob.dataCollectionId = @dcId;
20+
21+
DELETE ProcessingJobImageSweep
22+
FROM ProcessingJobImageSweep
23+
JOIN ProcessingJob
24+
WHERE ProcessingJob.processingJobId = ProcessingJobImageSweep.processingJobId AND
25+
ProcessingJob.dataCollectionId = @dcId;
26+
27+
DELETE AutoProcProgramMessage
28+
FROM AutoProcProgramMessage
29+
JOIN ProcessingJob
30+
JOIN AutoProcProgram
31+
WHERE ProcessingJob.processingJobId = AutoProcProgram.processingJobId AND
32+
AutoProcProgramMessage.autoProcProgramId = AutoProcProgram.autoProcProgramId AND
33+
ProcessingJob.dataCollectionId = @dcId;
34+
35+
DELETE AutoProcProgram
36+
FROM AutoProcProgram
37+
JOIN ProcessingJob
38+
WHERE ProcessingJob.processingJobId = AutoProcProgram.processingJobId AND
39+
ProcessingJob.dataCollectionId = @dcId;
40+
41+
DELETE
42+
FROM ProcessingJob
43+
WHERE dataCollectionId = @dcId;
44+
45+
DELETE AutoProcProgramMessage
46+
FROM AutoProcProgramMessage
47+
JOIN AutoProcProgram
48+
JOIN AutoProcIntegration
49+
WHERE AutoProcIntegration.autoProcProgramId = AutoProcProgram.autoProcProgramId AND
50+
AutoProcProgramMessage.autoProcProgramId = AutoProcProgram.autoProcProgramId AND
51+
AutoProcIntegration.dataCollectionId = @dcId;
52+
53+
DELETE AutoProcProgram
54+
FROM AutoProcProgram
55+
JOIN AutoProcIntegration
56+
WHERE AutoProcIntegration.autoProcProgramId = AutoProcProgram.autoProcProgramId AND
57+
AutoProcIntegration.dataCollectionId = @dcId;
58+
59+
DELETE
60+
FROM AutoProcIntegration
61+
WHERE dataCollectionId = @dcId;
62+
63+
DELETE
64+
FROM GridInfo
65+
WHERE dataCollectionId = @dcId;
66+
67+
DELETE
68+
FROM DataCollection
69+
WHERE dataCollectionId = @dcId;

0 commit comments

Comments
 (0)