# Generated by Django 5.2.8 on 2025-12-01 00:00

from django.db import migrations
from django.db.models import Q


def remove_clipboard_feature(apps, schema_editor):
    NodeFeature = apps.get_model("nodes", "NodeFeature")
    NodeFeatureAssignment = apps.get_model("nodes", "NodeFeatureAssignment")
    PeriodicTask = apps.get_model("django_celery_beat", "PeriodicTask")

    feature = NodeFeature.objects.filter(slug="clipboard-poll").first()
    if feature:
        NodeFeatureAssignment.objects.filter(feature=feature).delete()
        feature.delete()

    PeriodicTask.objects.filter(
        Q(name__startswith="poll_clipboard_node_")
        | Q(name__startswith="poll-clipboard-node-")
    ).delete()


class Migration(migrations.Migration):
    dependencies = [
        ("nodes", "0045_node_trusted"),
    ]

    operations = [
        migrations.RunPython(remove_clipboard_feature, migrations.RunPython.noop),
    ]
