# Generated by Django 4.2.9 on 2024-04-05 14:39

import json
from django.db import migrations, models


def convert_log_to_json(apps, schema_editor):
    Scrobble = apps.get_model("scrobbles", "Scrobble")
    for s in Scrobble.objects.filter(scrobble_log__isnull=False):
        s.scrobble_log = json.dumps({"migrated_data": s.scrobble_log})
        s.save(update_fields=["scrobble_log"])


class Migration(migrations.Migration):

    dependencies = [
        ("scrobbles", "0051_scrobble_timezone"),
    ]

    operations = [
        migrations.RunPython(convert_log_to_json),
        migrations.AlterField(
            model_name="scrobble",
            name="scrobble_log",
            field=models.JSONField(blank=True, null=True),
        ),
    ]
