<commit_before>from trac.db import Table, Column, Index, DatabaseManager
from trac.versioncontrol.cache import CACHE_YOUNGEST_REV

def do_upgrade(env, ver, cursor):
    """Modify the repository cache scheme.

    Now we use the 'youngest_rev' entry in the system table
    to explicitly store the youngest rev in the cache.
    """
    db = env.get_db_cnx()
    repos = env.get_repository(None, sync=False)
    youngest = repos.get_youngest_rev_in_cache(db) or ''
    # deleting first, for the 0.11dev and 0.10.4dev users
    cursor.execute("DELETE FROM system WHERE name=%s", (CACHE_YOUNGEST_REV,))
    cursor.execute("INSERT INTO system (name, value) VALUES (%s, %s)",
                   (CACHE_YOUNGEST_REV, youngest))<commit_msg>Upgrade database version 20 should succeed even for environment not using the versioncontrol subsystem. Closes #5015.<commit_after>from trac.db import Table, Column, Index, DatabaseManager
from trac.core import TracError
from trac.versioncontrol.cache import CACHE_YOUNGEST_REV

def do_upgrade(env, ver, cursor):
    """Modify the repository cache scheme (if needed)

    Now we use the 'youngest_rev' entry in the system table
    to explicitly store the youngest rev in the cache.
    """
    db = env.get_db_cnx()
    try:
        repos = env.get_repository(None, sync=False)
        youngest = repos.get_youngest_rev_in_cache(db) or ''
        # deleting first, for the 0.11dev and 0.10.4dev users
        cursor.execute("DELETE FROM system WHERE name=%s",
                       (CACHE_YOUNGEST_REV,))
        cursor.execute("INSERT INTO system (name, value) VALUES (%s, %s)",
                       (CACHE_YOUNGEST_REV, youngest))
    except TracError: # no repository available
        pass
        
{'fraction_non_alphanumeric': 0.0885566417481311, 'fraction_numerical': 0.011500862564692352, 'mean_word_length': 3.3069306930693068, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3672175', 'n_tokens_mistral': 555, 'n_tokens_neox': 517, 'n_words': 169}