def delete_integration_credential(mapper, connection, target):
    """When a Connection is deleted, also delete its IntegrationCredential if present."""
    if target.integration_credential_id:
        # Get the session
        session = Session.object_session(target)
        if session:
            # If we're in a session, use the session to delete the IntegrationCredential
            from airweave.models.integration_credential import IntegrationCredential

            credential = session.get(IntegrationCredential, target.integration_credential_id)
            if credential:
                session.delete(credential)
        else:
            # If we're not in a session, use the connection directly
            connection.execute(
                f"DELETE FROM integration_credential WHERE id = '{target.integration_credential_id}'"  # noqa: E501
            )
When a Connection is deleted, also delete its IntegrationCredential if present.
backend/airweave/models/connection.py