# Generated by Django 5.2.19 on 2026-11-28 16:08

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('tenancy', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='SyncChange',
            fields=[
                ('sequence', models.BigAutoField(primary_key=True, serialize=False)),
                ('entity_type', models.CharField(max_length=64)),
                ('entity_id', models.CharField(max_length=128)),
                ('action', models.CharField(max_length=32)),
                ('payload', models.JSONField(default=dict)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='sync_changes', to='tenancy.company')),
            ],
            options={
                'ordering': ['sequence'],
            },
        ),
        migrations.CreateModel(
            name='SyncOperation',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('device_id', models.CharField(max_length=128)),
                ('operation_id', models.CharField(max_length=128)),
                ('entity_type', models.CharField(max_length=64)),
                ('entity_id', models.CharField(max_length=128)),
                ('operation', models.CharField(max_length=32)),
                ('base_version', models.IntegerField(blank=True, null=True)),
                ('status', models.CharField(choices=[('APPLIED', 'Applied'), ('DUPLICATE', 'Duplicate'), ('CONFLICT', 'Conflict'), ('REJECTED', 'Rejected')], max_length=16)),
                ('response_payload', models.JSONField(default=dict)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='sync_operations', to='tenancy.company')),
            ],
            options={
                'ordering': ['-created_at'],
                'unique_together': {('company', 'device_id', 'operation_id')},
            },
        ),
    ]
