feat(store): add DeleteUser with cascading account deletion
This commit is contained in:
@@ -119,3 +119,17 @@ func (db *DB) ProvisionUser(ctx context.Context, oidcSub, displayName string) (i
|
||||
|
||||
return userID, tx.Commit()
|
||||
}
|
||||
|
||||
// DeleteUser permanently deletes userID's account. Every row that belongs
|
||||
// to it -- profile, workout kinds (and their paces), activities (and their
|
||||
// laps/samples/kind_assignments), sync_state, and sync_runs -- cascades
|
||||
// away via the ON DELETE CASCADE foreign keys in schema.sql, so this is a
|
||||
// single statement rather than per-table deletes. Irreversible; the API
|
||||
// layer gates this behind a UI confirmation (see
|
||||
// docs/superpowers/specs/2026-07-26-profile-deletion-design.md).
|
||||
func (db *DB) DeleteUser(ctx context.Context, userID int64) error {
|
||||
if _, err := db.ExecContext(ctx, `DELETE FROM users WHERE id = ?`, userID); err != nil {
|
||||
return fmt.Errorf("delete user %d: %w", userID, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user