def delete_parent_sync_and_connection(mapper, connection, target):
    """When a SourceConnection is deleted, also delete its parent Sync and Connection."""
    # Delete parent Sync if it exists
    if target.sync_id:
        # Get the session
        session = Session.object_session(target)
        if session:
            # If we're in a session, use the session to delete the Sync
            from airweave.models.sync import Sync

            sync = session.get(Sync, target.sync_id)
            if sync:
                session.delete(sync)
        else:
            # If we're not in a session, use the connection directly
            connection.execute(f"DELETE FROM sync WHERE id = '{target.sync_id}'")

    sleep(0.2)

    # Delete related Connection if it exists
    if target.connection_id:
        session = Session.object_session(target)
        if session:
            from airweave.models.connection import Connection

            related_connection = session.get(Connection, target.connection_id)
            if related_connection:
                session.delete(related_connection)
        else:
            connection.execute(f"DELETE FROM connection WHERE id = '{target.connection_id}'")
When a SourceConnection is deleted, also delete its parent Sync and Connection.
backend/airweave/models/source_connection.py