# Generated by Django 4.2.21 on 2025-06-27 13:32

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


class Migration(migrations.Migration):

    dependencies = [
        ('pretixbase', '0283_taxrule_default_taxrule_backfill'),
    ]

    operations = [
        migrations.CreateModel(
            name='OrderSyncResult',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)),
                ('sync_provider', models.CharField(max_length=128)),
                ('mapping_id', models.IntegerField()),
                ('external_object_type', models.CharField(max_length=128)),
                ('external_id_field', models.CharField(max_length=128)),
                ('id_value', models.CharField(max_length=128)),
                ('external_link_href', models.CharField(max_length=255, null=True)),
                ('external_link_display_name', models.CharField(max_length=255, null=True)),
                ('transmitted', models.DateTimeField(auto_now_add=True)),
                ('sync_info', models.JSONField()),
                ('order', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='sync_results', to='pretixbase.order')),
                ('order_position', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='sync_results', to='pretixbase.orderposition')),
            ],
            options={
                'indexes': [models.Index(fields=['order', 'sync_provider'], name='pretixbase__order_i_3e3c84_idx')],
            },
        ),
        migrations.CreateModel(
            name='OrderSyncQueue',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)),
                ('sync_provider', models.CharField(max_length=128)),
                ('triggered_by', models.CharField(max_length=128)),
                ('triggered', models.DateTimeField(auto_now_add=True)),
                ('failed_attempts', models.PositiveIntegerField(default=0)),
                ('not_before', models.DateTimeField(db_index=True)),
                ('need_manual_retry', models.CharField(null=True, max_length=20)),
                ('in_flight', models.BooleanField(default=False)),
                ('in_flight_since', models.DateTimeField(blank=True, null=True)),
                ('event', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='queued_sync_jobs', to='pretixbase.event')),
                ('order', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='queued_sync_jobs', to='pretixbase.order')),
            ],
            options={
                'ordering': ('triggered',),
                'unique_together': {('order', 'sync_provider', 'in_flight')},
            },
        ),
    ]
