# Generated by Django 5.2.1 on 2025-08-25 18:07

import django.db.models.deletion
import django.utils.timezone
import model_utils.fields
import uuid
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('contenttypes', '0002_remove_content_type_name'),
        ('epdb', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='ExternalDatabase',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')),
                ('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')),
                ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
                ('name', models.CharField(max_length=100, unique=True, verbose_name='Database Name')),
                ('full_name', models.CharField(blank=True, max_length=255, verbose_name='Full Database Name')),
                ('description', models.TextField(blank=True, verbose_name='Description')),
                ('base_url', models.URLField(blank=True, null=True, verbose_name='Base URL')),
                ('url_pattern', models.CharField(blank=True, help_text="URL pattern with {id} placeholder, e.g., 'https://pubchem.ncbi.nlm.nih.gov/compound/{id}'", max_length=500, verbose_name='URL Pattern')),
                ('is_active', models.BooleanField(default=True, verbose_name='Is Active')),
            ],
            options={
                'verbose_name': 'External Database',
                'verbose_name_plural': 'External Databases',
                'db_table': 'epdb_external_database',
                'ordering': ['name'],
            },
        ),
        migrations.AlterModelOptions(
            name='apitoken',
            options={'ordering': ['-created'], 'verbose_name': 'API Token', 'verbose_name_plural': 'API Tokens'},
        ),
        migrations.AlterModelOptions(
            name='edge',
            options={},
        ),
        migrations.RemoveField(
            model_name='edge',
            name='polymorphic_ctype',
        ),
        migrations.AddField(
            model_name='apitoken',
            name='is_active',
            field=models.BooleanField(default=True, help_text='Whether this token is active'),
        ),
        migrations.AddField(
            model_name='apitoken',
            name='modified',
            field=model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified'),
        ),
        migrations.AddField(
            model_name='applicabilitydomain',
            name='functional_groups',
            field=models.JSONField(blank=True, default=dict, null=True),
        ),
        migrations.AddField(
            model_name='mlrelativereasoning',
            name='app_domain',
            field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.SET_NULL, to='epdb.applicabilitydomain'),
        ),
        migrations.AlterField(
            model_name='apitoken',
            name='created',
            field=model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created'),
        ),
        migrations.AlterField(
            model_name='apitoken',
            name='expires_at',
            field=models.DateTimeField(blank=True, help_text='Token expiration time (null for no expiration)', null=True),
        ),
        migrations.AlterField(
            model_name='apitoken',
            name='hashed_key',
            field=models.CharField(help_text='SHA-256 hash of the token key', max_length=128, unique=True),
        ),
        migrations.AlterField(
            model_name='apitoken',
            name='name',
            field=models.CharField(help_text='Descriptive name for this token', max_length=100),
        ),
        migrations.AlterField(
            model_name='apitoken',
            name='user',
            field=models.ForeignKey(help_text='User who owns this token', on_delete=django.db.models.deletion.CASCADE, related_name='api_tokens', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AlterField(
            model_name='applicabilitydomain',
            name='num_neighbours',
            field=models.IntegerField(default=5),
        ),
        migrations.AlterModelTable(
            name='apitoken',
            table='epdb_api_token',
        ),
        migrations.CreateModel(
            name='ExternalIdentifier',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')),
                ('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')),
                ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
                ('object_id', models.IntegerField()),
                ('identifier_value', models.CharField(max_length=255, verbose_name='Identifier Value')),
                ('url', models.URLField(blank=True, null=True, verbose_name='Direct URL')),
                ('is_primary', models.BooleanField(default=False, help_text='Mark this as the primary identifier for this database', verbose_name='Is Primary')),
                ('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.contenttype')),
                ('database', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='epdb.externaldatabase', verbose_name='External Database')),
            ],
            options={
                'verbose_name': 'External Identifier',
                'verbose_name_plural': 'External Identifiers',
                'db_table': 'epdb_external_identifier',
                'indexes': [models.Index(fields=['content_type', 'object_id'], name='epdb_extern_content_b76813_idx'), models.Index(fields=['database', 'identifier_value'], name='epdb_extern_databas_486422_idx')],
                'unique_together': {('content_type', 'object_id', 'database', 'identifier_value')},
            },
        ),
    ]
