Permanently removes the record from the database.
(self, db_session: "Session", actor: Optional["User"] = None)
| 441 | |
| 442 | @handle_db_timeout |
| 443 | def hard_delete(self, db_session: "Session", actor: Optional["User"] = None) -> None: |
| 444 | """Permanently removes the record from the database.""" |
| 445 | logger.debug(f"Hard deleting {self.__class__.__name__} with ID: {self.id} with actor={actor}") |
| 446 | |
| 447 | with db_session as session: |
| 448 | try: |
| 449 | session.delete(self) |
| 450 | session.commit() |
| 451 | except Exception as e: |
| 452 | session.rollback() |
| 453 | logger.exception(f"Failed to hard delete {self.__class__.__name__} with ID {self.id}") |
| 454 | raise ValueError(f"Failed to hard delete {self.__class__.__name__} with ID {self.id}: {e}") |
| 455 | else: |
| 456 | logger.debug(f"{self.__class__.__name__} with ID {self.id} successfully hard deleted") |
| 457 | |
| 458 | @handle_db_timeout |
| 459 | def update(self, db_session: Session, actor: Optional["User"] = None, no_commit: bool = False) -> "SqlalchemyBase": |
no test coverage detected