diff --git a/dal/db_query/queries.sql b/dal/db_query/queries.sql index ac1e937..7c543d9 100644 --- a/dal/db_query/queries.sql +++ b/dal/db_query/queries.sql @@ -678,14 +678,17 @@ SELECT * FROM tokens WHERE Expiration <= TO_TIMESTAMP(EXTRACT(EPOCH FROM NOW()) -- name: WebhookDelete :exec WITH userd AS ( UPDATE users SET Deleted = true WHERE AmoUserID = $1 RETURNING AccountID -), -tokend AS ( - DELETE FROM tokens WHERE AccountID IN (SELECT AccountID FROM userd) RETURNING * ) -SELECT * FROM tokend; +DELETE FROM tokens WHERE AccountID IN (SELECT AccountID FROM userd); -- name: SoftDeleteAccount :exec -UPDATE users SET Deleted = TRUE WHERE AccountID = $1; +WITH userd AS ( + SELECT AmoUserID FROM users WHERE users.AccountID = $1 +), + tokend AS ( + UPDATE users SET Deleted = true WHERE AmoUserID IN (SELECT AmoUserID FROM userd) RETURNING users.AccountID + ) +DELETE FROM tokens WHERE tokens.AccountID IN (SELECT AccountID FROM tokend); -- name: GetCurrentAccount :one SELECT * FROM users WHERE AccountID = $1; diff --git a/dal/sqlcgen/queries.sql.go b/dal/sqlcgen/queries.sql.go index f98b31d..1477735 100644 --- a/dal/sqlcgen/queries.sql.go +++ b/dal/sqlcgen/queries.sql.go @@ -3028,7 +3028,13 @@ func (q *Queries) SetQuizSettings(ctx context.Context, arg SetQuizSettingsParams } const softDeleteAccount = `-- name: SoftDeleteAccount :exec -UPDATE users SET Deleted = TRUE WHERE AccountID = $1 +WITH userd AS ( + SELECT AmoUserID FROM users WHERE users.AccountID = $1 +), + tokend AS ( + UPDATE users SET Deleted = true WHERE AmoUserID IN (SELECT AmoUserID FROM userd) RETURNING users.AccountID + ) +DELETE FROM tokens WHERE tokens.AccountID IN (SELECT AccountID FROM tokend) ` func (q *Queries) SoftDeleteAccount(ctx context.Context, accountid string) error { @@ -3211,11 +3217,8 @@ func (q *Queries) UpdateUtmsFields(ctx context.Context, dollar_1 []int32) error const webhookDelete = `-- name: WebhookDelete :exec WITH userd AS ( UPDATE users SET Deleted = true WHERE AmoUserID = $1 RETURNING AccountID -), -tokend AS ( - DELETE FROM tokens WHERE AccountID IN (SELECT AccountID FROM userd) RETURNING accountid, refreshtoken, accesstoken, authcode, expiration, createdat ) -SELECT accountid, refreshtoken, accesstoken, authcode, expiration, createdat FROM tokend +DELETE FROM tokens WHERE AccountID IN (SELECT AccountID FROM userd) ` func (q *Queries) WebhookDelete(ctx context.Context, amouserid int32) error {