dete accounts
All checks were successful
Build and Push Docker Image / build_and_push (push) Successful in 2m1s
All checks were successful
Build and Push Docker Image / build_and_push (push) Successful in 2m1s
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user