# Generated by Django 5.2.7 on 2025-10-11 07:38

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


class Migration(migrations.Migration):

    dependencies = [
        ('knowledge', '0002_alter_file_source_type'),
    ]

    operations = [
        migrations.CreateModel(
            name='Tag',
            fields=[
                ('create_time', models.DateTimeField(auto_now_add=True, db_index=True, verbose_name='创建时间')),
                ('update_time', models.DateTimeField(auto_now=True, db_index=True, verbose_name='修改时间')),
                ('id', models.UUIDField(default=uuid_utils.compat.uuid7, editable=False, primary_key=True, serialize=False, verbose_name='主键id')),
                ('key', models.CharField(db_index=True, max_length=64, verbose_name='标签键')),
                ('value', models.CharField(db_index=True, max_length=128, verbose_name='标签值')),
                ('knowledge', models.ForeignKey(db_constraint=False, on_delete=django.db.models.deletion.DO_NOTHING, to='knowledge.knowledge', verbose_name='知识库')),
            ],
            options={
                'db_table': 'tag',
            },
        ),
        migrations.CreateModel(
            name='DocumentTag',
            fields=[
                ('create_time', models.DateTimeField(auto_now_add=True, db_index=True, verbose_name='创建时间')),
                ('update_time', models.DateTimeField(auto_now=True, db_index=True, verbose_name='修改时间')),
                ('id', models.UUIDField(default=uuid_utils.compat.uuid7, editable=False, primary_key=True, serialize=False, verbose_name='主键id')),
                ('document', models.ForeignKey(db_constraint=False, on_delete=django.db.models.deletion.DO_NOTHING, to='knowledge.document', verbose_name='文档')),
                ('tag', models.ForeignKey(db_constraint=False, on_delete=django.db.models.deletion.DO_NOTHING, to='knowledge.tag', verbose_name='标签')),
            ],
            options={
                'db_table': 'document_tag',
            },
        ),
        migrations.AddIndex(
            model_name='tag',
            index=models.Index(fields=['knowledge', 'key'], name='tag_knowled_cba590_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='tag',
            unique_together={('knowledge', 'key', 'value')},
        ),
        migrations.AlterUniqueTogether(
            name='documenttag',
            unique_together={('document', 'tag')},
        ),
    ]
