# Generated by Django 4.2.23 on 2025-08-13 09:06

from django.db import migrations, models

def migrate_forwards(app, schema_editor):
    EventSettingsStore = app.get_model('pretixbase', 'Event_SettingsStore')

    for setting in EventSettingsStore.objects.all():
        if setting.key == "uic_barcode_security_provider_rics" and setting.value:
            EventSettingsStore.objects.create(
                object=setting.object,
                key="uic_barcode_security_provider_org_code",
                value=f"{int(setting.value):04}"
            )
            setting.delete()
        elif setting.key == "uic_barcode_security_provider_ia5" and setting.value:
            EventSettingsStore.objects.create(
                object=setting.object,
                key="uic_barcode_security_provider_alt_code_table",
                value=""
            )
            EventSettingsStore.objects.create(
                object=setting.object,
                key="uic_barcode_security_provider_alt_code_value",
                value=setting.value
            )
            setting.delete()

class Migration(migrations.Migration):
    dependencies = [
        ('pretix_uic_barcode', '0005_googleeventlog'),
    ]

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