Creating a Custom Sorting only using a Subscriber or a AbstractListingProcessor

I am trying to add a custom sorting that does sorting depending on my own entity.value and as the document is suggesting, it is possible to create custom sorting either through a database migration or Subscriber and after more digging I found out that in the future this method won’t be available in the future and that it would be replaced with the AbstractListingProcessor but both of them will not create a new value for my custom sorting in the database and gives me the custom-sorting key isn't found error. and I would like to know what I am doing wrong I did the same exact steps that Create individual sorting at runtime document suggest (when following the debugger it looks that my custom sorting is being added to the $availableSorting but it isn’t added to the database). any help would be appreciated.

    $criteria->getAssociation('deepLearning')->addSorting(new FieldSorting('clicked', FieldSorting::DESCENDING));

    /** @var ProductSortingCollection $availableSortings */
    $availableSorting = $criteria->getExtension('sortings') ?? new ProductSortingCollection();

    $customSortingEntity = new ProductSortingEntity();
    $customSortingEntity ->setId(Uuid::randomHex());
    $customSortingEntity ->setActive(true);
    $customSortingEntity ->setTranslated(['label' => 'Custom Sorting']);
    $customSortingEntity ->setKey('custom-sorting');
    $customSortingEntity ->setPriority(5);
    $customSortingEntity ->setFields([
            'field' => 'deepLearning.clicked',
            'order' => 'desc',
            'priority' => 1,
            'naturalSorting' => 0,

    $availableSorting->add($customSortingEntity );

    $criteria->addExtension('sortings', $availableSorting);