diff --git a/aries_cloudagent/connections/models/conn_record.py b/aries_cloudagent/connections/models/conn_record.py index 10fdb91284..24fc2fbf34 100644 --- a/aries_cloudagent/connections/models/conn_record.py +++ b/aries_cloudagent/connections/models/conn_record.py @@ -522,14 +522,24 @@ async def delete_record(self, session: ProfileSession): """ await super().delete_record(session) + storage = session.inject(BaseStorage) # Delete metadata if self.connection_id: - storage = session.inject(BaseStorage) await storage.delete_all_records( self.RECORD_TYPE_METADATA, {"connection_id": self.connection_id}, ) + # Delete attached messages + await storage.delete_all_records( + self.RECORD_TYPE_REQUEST, + {"connection_id": self.connection_id}, + ) + await storage.delete_all_records( + self.RECORD_TYPE_INVITATION, + {"connection_id": self.connection_id}, + ) + async def abandon(self, session: ProfileSession, *, reason: Optional[str] = None): """Set state to abandoned.""" reason = reason or "Connectin abandoned"