domain_delete.go: clean up SQL

This commit is contained in:
Adhityaa Chandrasekar 2019-12-28 20:53:45 -08:00
parent f6d6a1f77f
commit 80dc91ca05

View File

@ -10,8 +10,7 @@ func domainDelete(domain string) error {
} }
statement := ` statement := `
DELETE FROM DELETE FROM domains
domains
WHERE domain = $1; WHERE domain = $1;
` `
_, err := db.Exec(statement, domain) _, err := db.Exec(statement, domain)
@ -25,7 +24,7 @@ func domainDelete(domain string) error {
` `
_, err = db.Exec(statement, domain) _, err = db.Exec(statement, domain)
if err != nil { if err != nil {
logger.Errorf("cannot delete views: %v", err) logger.Errorf("cannot delete domain from views: %v", err)
return errorInternal return errorInternal
} }
@ -35,7 +34,17 @@ func domainDelete(domain string) error {
` `
_, err = db.Exec(statement, domain) _, err = db.Exec(statement, domain)
if err != nil { 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 return errorInternal
} }