code: func (ssa *SQLStorageAuthority) DeactivateAuthorization(ctx context.Context, id string) error {
  	tx, err := ssa.dbMap.Begin()
  	if err != nil {
  		return err
  	}
  	txWithCtx := tx.WithContext(ctx)
  
  	if existingPending(txWithCtx, id) {
  		authzObj, err := txWithCtx.Get(&pendingauthzModel{}, id)
  		if err != nil {
  			return Rollback(tx, err)
  		}
  		if authzObj == nil {
  			// InternalServerError because existingPending already told us it existed
  			return Rollback(tx, berrors.InternalServerError("failure retrieving pending authorization"))
  		}
  		authz := authzObj.(*pendingauthzModel)
  		if authz.Status != core.StatusPending {
  			return Rollback(tx, berrors.WrongAuthorizationStateError("authorization not pending"))
  		}
  		authz.Status = core.StatusDeactivated
  		err = txWithCtx.Insert(&authzModel{authz.Authorization})
  		if err != nil {
  			return Rollback(tx, err)
  		}
  		result, err := txWithCtx.Delete(authzObj)
  		if err != nil {
  			return Rollback(tx, err)
  		}
  		if result != 1 {
  			return Rollback(tx, berrors.InternalServerError("wrong number of rows deleted: expected 1, got %d", result))
  		}
  	} else {
  		_, err = txWithCtx.Exec(
  			`UPDATE authz SET status = ? WHERE id = ? and status = ?`,
  			string(core.StatusDeactivated),
  			id,
  			string(core.StatusValid),
  		)
  		if err != nil {
  			return Rollback(tx, err)
  		}
  	}
  
  	return tx.Commit()
  }
docs: // DeactivateAuthorization deactivates a currently valid or pending authorization