From 80dc91ca05e38a0386e72706199d6a721af908fb Mon Sep 17 00:00:00 2001 From: Adhityaa Chandrasekar Date: Sat, 28 Dec 2019 20:53:45 -0800 Subject: [PATCH] domain_delete.go: clean up SQL --- api/domain_delete.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/api/domain_delete.go b/api/domain_delete.go index c9ede5d..a4e61f7 100644 --- a/api/domain_delete.go +++ b/api/domain_delete.go @@ -10,8 +10,7 @@ func domainDelete(domain string) error { } statement := ` - DELETE FROM - domains + DELETE FROM domains WHERE domain = $1; ` _, err := db.Exec(statement, domain) @@ -25,7 +24,7 @@ func domainDelete(domain string) error { ` _, err = db.Exec(statement, domain) if err != nil { - logger.Errorf("cannot delete views: %v", err) + logger.Errorf("cannot delete domain from views: %v", err) return errorInternal } @@ -35,7 +34,17 @@ func domainDelete(domain string) error { ` _, err = db.Exec(statement, domain) if err != nil { - logger.Errorf("cannot delete domain moderators: %v", err) + logger.Errorf("cannot delete domain from moderators: %v", err) + return errorInternal + } + + statement = ` + DELETE FROM ssotokens + WHERE ssotokens.domain = $1; + ` + _, err = db.Exec(statement, domain) + if err != nil { + logger.Errorf("cannot delete domain from ssotokens: %v", err) return errorInternal }