Deleting orphaned BuildResultSummary records

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

Database modification

This resolution includes manual modifications to Bamboo database. Please backup your data before proceeding!

 

Existence of orphaned BuildResultSummary records can be confirmed with the following SQL query:

SELECT DISTINCT BRS.BUILD_KEY
 FROM BUILDRESULTSUMMARY BRS
 LEFT JOIN BUILD B ON BRS.BUILD_KEY = B.FULL_KEY
WHERE B.FULL_KEY IS NULL;

Orphaned records have to be removed considering all DB relations:

Bamboo 2.7 - Bamboo 3.2
DELETE FROM BUILDRESULTSUMMARY_CUSTOMDATA WHERE BUILDRESULTSUMMARY_ID IN
(
 SELECT BUILDRESULTSUMMARY_ID
 FROM BUILDRESULTSUMMARY BRS
 LEFT JOIN BUILD B ON BRS.BUILD_KEY = B.FULL_KEY
 WHERE B.FULL_KEY IS NULL
);

DELETE FROM BRS_LINKEDJIRAISSUES WHERE BUILDRESULTSUMMARY_ID IN
(
 SELECT BUILDRESULTSUMMARY_ID
 FROM BUILDRESULTSUMMARY BRS
 LEFT JOIN BUILD B ON BRS.BUILD_KEY = B.FULL_KEY
 WHERE B.FULL_KEY IS NULL
);

DELETE FROM COMMIT_FILES WHERE COMMIT_ID IN
(
 SELECT COMMIT_ID
 FROM USER_COMMIT 
 WHERE BUILDRESULTSUMMARY_ID IN
 (
 SELECT BUILDRESULTSUMMARY_ID
 FROM BUILDRESULTSUMMARY BRS
 LEFT JOIN BUILD B ON BRS.BUILD_KEY = B.FULL_KEY
 WHERE B.FULL_KEY IS NULL
 )
);

DELETE FROM USER_COMMIT WHERE BUILDRESULTSUMMARY_ID IN
(
 SELECT BUILDRESULTSUMMARY_ID
 FROM BUILDRESULTSUMMARY BRS
 LEFT JOIN BUILD B ON BRS.BUILD_KEY = B.FULL_KEY
 WHERE B.FULL_KEY IS NULL
);

DELETE FROM TEST_ERROR WHERE RESULT_ID IN
(
 SELECT TEST_CASE_RESULT_ID FROM TEST_CASE_RESULT WHERE TEST_CLASS_RESULT_ID IN
 (
 SELECT TEST_CLASS_RESULT_ID FROM TEST_CLASS_RESULT WHERE BUILDRESULTSUMMARY_ID IN
 (
 SELECT BUILDRESULTSUMMARY_ID
 FROM BUILDRESULTSUMMARY BRS
 LEFT JOIN BUILD B ON BRS.BUILD_KEY = B.FULL_KEY
 WHERE B.FULL_KEY IS NULL
 )
 )
);

DELETE FROM TEST_CASE_RESULT WHERE TEST_CLASS_RESULT_ID IN
(
 SELECT TEST_CLASS_RESULT_ID FROM TEST_CLASS_RESULT WHERE BUILDRESULTSUMMARY_ID IN
 (
 SELECT BUILDRESULTSUMMARY_ID
 FROM BUILDRESULTSUMMARY BRS
 LEFT JOIN BUILD B ON BRS.BUILD_KEY = B.FULL_KEY
 WHERE B.FULL_KEY IS NULL
 )
);

DELETE FROM TEST_CLASS_RESULT WHERE BUILDRESULTSUMMARY_ID IN
(
 SELECT BUILDRESULTSUMMARY_ID
 FROM BUILDRESULTSUMMARY BRS
 LEFT JOIN BUILD B ON BRS.BUILD_KEY = B.FULL_KEY
 WHERE B.FULL_KEY IS NULL
);

DELETE FROM BRS_ARTIFACT_LINK WHERE BUILDRESULTSUMMARY_ID IN
(
 SELECT BUILDRESULTSUMMARY_ID
 FROM BUILDRESULTSUMMARY BRS
 LEFT JOIN BUILD B ON BRS.BUILD_KEY = B.FULL_KEY
 WHERE B.FULL_KEY IS NULL
);

DELETE FROM USER_COMMENT WHERE BUILDRESULTSUMMARY_ID IN
(
 SELECT BUILDRESULTSUMMARY_ID
 FROM BUILDRESULTSUMMARY BRS
 LEFT JOIN BUILD B ON BRS.BUILD_KEY = B.FULL_KEY
 WHERE B.FULL_KEY IS NULL
);

DELETE FROM BUILDRESULTSUMMARY WHERE BUILDRESULTSUMMARY_ID IN
(
 SELECT BUILDRESULTSUMMARY_ID
 FROM BUILDRESULTSUMMARY BRS
 LEFT JOIN BUILD B ON BRS.BUILD_KEY = B.FULL_KEY
 WHERE B.FULL_KEY IS NULL 
) AND BUILD_TYPE <> 'CHAIN';

DELETE FROM CHAIN_STAGE_RESULT WHERE CHAINRESULT_ID IN
(
 SELECT BUILDRESULTSUMMARY_ID
 FROM BUILDRESULTSUMMARY BRS
 LEFT JOIN BUILD B ON BRS.BUILD_KEY = B.FULL_KEY
 WHERE B.FULL_KEY IS NULL
);

DELETE FROM BUILDRESULTSUMMARY WHERE BUILDRESULTSUMMARY_ID IN
(
 SELECT BUILDRESULTSUMMARY_ID
 FROM BUILDRESULTSUMMARY BRS
 LEFT JOIN BUILD B ON BRS.BUILD_KEY = B.FULL_KEY
 WHERE B.FULL_KEY IS NULL 
);
最終更新日 2011 年 11 月 22 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.