# Generated by Django 4.2.20 on 2025-03-31 11:55
from __future__ import annotations

from django.db import migrations


def _remove_remote_datasets(apps, schema_editor):
    Dataset = apps.get_model("datasets", "Dataset")
    remote_datasets = Dataset.objects.filter(endpoint_url__isnull=False).exclude(endpoint_url="")
    for dataset in remote_datasets:
        print(f"- Deleting {dataset.name}")
        dataset.delete()


class Migration(migrations.Migration):

    dependencies = [
        ("datasets", "0019_datasettable_enable_export"),
    ]

    operations = [
        migrations.RunPython(
            _remove_remote_datasets,
            migrations.RunPython.noop,
        ),
        migrations.RemoveField(
            model_name="dataset",
            name="endpoint_url",
        ),
    ]
