# Generated by Django 6.0.1 on 2026-01-15 12:02

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('contenttypes', '0002_remove_content_type_name'),
        ('organizations', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='PXSource',
            fields=[
                ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('name_en', models.CharField(help_text='Source name in English', max_length=200)),
                ('name_ar', models.CharField(blank=True, help_text='Source name in Arabic', max_length=200)),
                ('description', models.TextField(blank=True, help_text='Detailed description')),
                ('is_active', models.BooleanField(db_index=True, default=True, help_text='Whether this source is active for selection')),
            ],
            options={
                'verbose_name': 'PX Source',
                'verbose_name_plural': 'PX Sources',
                'ordering': ['name_en'],
                'indexes': [models.Index(fields=['is_active', 'name_en'], name='px_sources__is_acti_ea1b54_idx')],
            },
        ),
        migrations.CreateModel(
            name='SourceUsage',
            fields=[
                ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('object_id', models.UUIDField(help_text='ID of related object')),
                ('content_type', models.ForeignKey(help_text='Type of related object', on_delete=django.db.models.deletion.CASCADE, to='contenttypes.contenttype')),
                ('hospital', models.ForeignKey(blank=True, help_text='Hospital where this source was used', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='source_usage_records', to='organizations.hospital')),
                ('source', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='usage_records', to='px_sources.pxsource')),
                ('user', models.ForeignKey(blank=True, help_text='User who selected this source', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='source_usage_records', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'Source Usage',
                'verbose_name_plural': 'Source Usages',
                'ordering': ['-created_at'],
                'indexes': [models.Index(fields=['source', '-created_at'], name='px_sources__source__13a9ae_idx'), models.Index(fields=['content_type', 'object_id'], name='px_sources__content_30cb33_idx'), models.Index(fields=['hospital', '-created_at'], name='px_sources__hospita_a0479a_idx'), models.Index(fields=['created_at'], name='px_sources__created_8606b0_idx')],
                'unique_together': {('content_type', 'object_id')},
            },
        ),
        migrations.CreateModel(
            name='SourceUser',
            fields=[
                ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('is_active', models.BooleanField(db_index=True, default=True, help_text='Whether this source user is active')),
                ('can_create_complaints', models.BooleanField(default=True, help_text='User can create complaints from this source')),
                ('can_create_inquiries', models.BooleanField(default=True, help_text='User can create inquiries from this source')),
                ('source', models.ForeignKey(help_text='Source managed by this user', on_delete=django.db.models.deletion.CASCADE, related_name='source_users', to='px_sources.pxsource')),
                ('user', models.OneToOneField(help_text='User who manages this source', on_delete=django.db.models.deletion.CASCADE, related_name='source_user_profile', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'Source User',
                'verbose_name_plural': 'Source Users',
                'ordering': ['source__name_en'],
                'indexes': [models.Index(fields=['user', 'is_active'], name='px_sources__user_id_40a726_idx'), models.Index(fields=['source', 'is_active'], name='px_sources__source__eb51c5_idx')],
                'unique_together': {('user', 'source')},
            },
        ),
    ]
