dete accounts
All checks were successful
Build and Push Docker Image / build_and_push (push) Successful in 2m1s

This commit is contained in:
Arnaud Delcasse
2026-01-13 15:33:38 +01:00
parent c958736472
commit 44f5a3d182
10 changed files with 221 additions and 28 deletions

View File

@@ -420,6 +420,34 @@ func (psql PostgresqlStorage) UpdateAccount(account Account) error {
return nil
}
func (psql PostgresqlStorage) DeleteAccount(id string) error {
tx, err := psql.DbConnection.BeginTx(context.Background(), nil)
if err != nil {
return err
}
defer tx.Rollback()
// Delete authentication info
req := fmt.Sprintf(`DELETE FROM %s WHERE account_id = $1`, psql.Tables["accounts_auth_local"])
_, err = tx.Exec(req, id)
if err != nil {
return err
}
// Mark account as deleted
req = fmt.Sprintf(`UPDATE %s SET deleted = true WHERE id = $1`, psql.Tables["accounts"])
_, err = tx.Exec(req, id)
if err != nil {
return err
}
if err := tx.Commit(); err != nil {
return err
}
return nil
}
func (psql PostgresqlStorage) Migrate() error {
ctx := context.Background()
driver, err := postgres.Open(psql.DbConnection)