import logging

from pathlib import Path

from im360.plugins.waf_rules_configurator import WAF_CONFIGURATOR_CRON_PATH

logger = logging.getLogger(__name__)


def migrate(migrator, database, fake=False, **kwargs):
    if fake:
        # Nothing to do in fake mode, it used to prepare models to following
        # migrations
        return

    try:
        Path(WAF_CONFIGURATOR_CRON_PATH).unlink(missing_ok=True)
    except Exception as e:
        logger.error(
            "Something wrong happened in migration 005_ip_network_v6_fix %r",
            e,
        )


def rollback(migrator, database, fake=False, **kwargs):
    """Write your rollback migrations here."""
    pass
