From d1181872d9ebb7e77ba6dbd1742bcd63080fa9b7 Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Fri, 17 Jun 2022 22:24:10 +0100 Subject: [PATCH] Add dbconsistency checks for Stopwatches It appears possible that stopwatches can become orphaned or have been orphaned in the past. This PR adds Orphan checks for Stopwatches. Signed-off-by: Andrew Thornton --- modules/doctor/dbconsistency.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/doctor/dbconsistency.go b/modules/doctor/dbconsistency.go index b23807cca278f..349a2121cf572 100644 --- a/modules/doctor/dbconsistency.go +++ b/modules/doctor/dbconsistency.go @@ -199,6 +199,12 @@ func checkDBConsistency(ctx context.Context, logger log.Logger, autofix bool) er // find OAuth2AuthorizationCode without existing OAuth2Grant genericOrphanCheck("Orphaned OAuth2AuthorizationCode without existing OAuth2Grant", "oauth2_authorization_code", "oauth2_grant", "oauth2_authorization_code.grant_id=oauth2_grant.id"), + // find stopwatches without existing user + genericOrphanCheck("Orphaned Stopwatches without existing User", + "stopwatch", "user", "stopwatch.user_id=user.id"), + // find stopwatches without existing issue + genericOrphanCheck("Orphaned Stopwatches without existing Issue", + "stopwatch", "issue", "stopwatch.issue_id=issue.id"), ) for _, c := range consistencyChecks {