# Generated by Django 4.2.4 on 2023-08-10 14:51

import django.db.models.deletion
from django.db import migrations, models


def add_default_url(apps, schema_editor):
    db_alias = schema_editor.connection.alias

    Url = apps.get_model("fingerprint", "Url")
    default_url = Url.objects.using(db_alias).create(value="?")

    RequestFingerprint = apps.get_model("fingerprint", "RequestFingerprint")
    RequestFingerprint.objects.using(db_alias).update(url=default_url)

    BrowserFingerprint = apps.get_model("fingerprint", "BrowserFingerprint")
    BrowserFingerprint.objects.using(db_alias).update(url=default_url)


class Migration(migrations.Migration):
    dependencies = [
        (
            "fingerprint",
            "0002_url_browserfingerprint_fingerprint_url_id_9faee4_idx_and_more",
        ),
    ]

    operations = [
        migrations.RunPython(add_default_url, migrations.RunPython.noop),
        migrations.AlterField(
            model_name="browserfingerprint",
            name="url",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="%(model_name)ss",
                to="fingerprint.url",
            ),
        ),
        migrations.AlterField(
            model_name="requestfingerprint",
            name="url",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="%(model_name)ss",
                to="fingerprint.url",
            ),
        ),
    ]
