<commit_before>import subprocess
import time

from moulinette import m18n
from yunohost.utils.error import YunohostError, YunohostValidationError
from moulinette.utils.log import getActionLogger

from yunohost.tools import Migration
from yunohost.utils.filesystem import free_space_in_directory, space_used_by_directory

logger = getActionLogger("yunohost.migration")


class MyMigration(Migration):

    "Migrate DBs from Postgresql 11 to 13 after migrating to Bullseye"

    dependencies = ["migrate_to_bullseye"]

    def run(self):

        if not self.package_is_installed("postgresql-11"):
            logger.warning(m18n.n("migration_0023_postgresql_11_not_installed"))
            return

        if not self.package_is_installed("postgresql-13"):
            raise YunohostValidationError("migration_0023_postgresql_13_not_installed")

        # Make sure there's a 11 cluster
        try:<commit_msg>postgresql 11->13 migration: skip if no yunohost app depend on postgresql<commit_after>import subprocess
import time

from moulinette import m18n
from yunohost.utils.error import YunohostError, YunohostValidationError
from moulinette.utils.log import getActionLogger

from yunohost.tools import Migration
from yunohost.utils.filesystem import free_space_in_directory, space_used_by_directory

logger = getActionLogger("yunohost.migration")


class MyMigration(Migration):

    "Migrate DBs from Postgresql 11 to 13 after migrating to Bullseye"

    dependencies = ["migrate_to_bullseye"]

    def run(self):

        if os.system('grep -A10 "ynh-deps" /var/lib/dpkg/status | grep "Package:\|Depends:" | grep -B1 postgresql') != 0:
            logger.info("No YunoHost app seem to require postgresql... Skipping!")
            return

        if not self.package_is_installed("postgresql-11"):
            logger.warning(m18n.n("migration_0023_postgresql_11_not_installed"))
            return

        if not self.package_is_installed("postgresql-13"):
            raise YunohostValidationError("migration_0023_postgresql_13_not_installed")

        # Make sure there's a 11 cluster
        try:
{'fraction_non_alphanumeric': 0.07458432304038004, 'fraction_numerical': 0.028503562945368172, 'mean_word_length': 4.026252983293556, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '5989980', 'n_tokens_mistral': 709, 'n_tokens_neox': 648, 'n_words': 153}