from django.apps import AppConfig
from django.db.models.signals import post_migrate

def create_site_config(sender, **kwargs):
    """
    Ensure the SiteConfiguration singleton exists after migrations.
    """
    from .models import SiteConfiguration
    try:
        SiteConfiguration.get_solo()
    except Exception:
        pass

class ConfigurationConfig(AppConfig):
    default_auto_field = 'django.db.models.BigAutoField'
    name = 'configuration'

    def ready(self):
        # Spustí create_site_config po dokončení migrací
        post_migrate.connect(create_site_config, sender=self)


