50 lines
2.2 KiB
Python
50 lines
2.2 KiB
Python
from django.conf import settings
|
|
from django.db import migrations, models
|
|
import django.db.models.deletion
|
|
import uuid
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
initial = True
|
|
|
|
dependencies = [
|
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
]
|
|
|
|
operations = [
|
|
migrations.CreateModel(
|
|
name="Conversation",
|
|
fields=[
|
|
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
|
|
("uuid", models.UUIDField(db_index=True, default=uuid.uuid4, editable=False, unique=True)),
|
|
("title", models.CharField(blank=True, default="", max_length=255)),
|
|
("farm_context", models.JSONField(blank=True, default=dict)),
|
|
("created_at", models.DateTimeField(auto_now_add=True)),
|
|
("updated_at", models.DateTimeField(auto_now=True)),
|
|
("owner", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name="farm_ai_conversations", to=settings.AUTH_USER_MODEL)),
|
|
],
|
|
options={
|
|
"db_table": "farm_ai_conversations",
|
|
"ordering": ["-updated_at", "-created_at"],
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name="Message",
|
|
fields=[
|
|
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
|
|
("uuid", models.UUIDField(db_index=True, default=uuid.uuid4, editable=False, unique=True)),
|
|
("role", models.CharField(choices=[("user", "User"), ("assistant", "Assistant")], max_length=32)),
|
|
("content", models.TextField(blank=True, default="")),
|
|
("images", models.JSONField(blank=True, default=list)),
|
|
("raw_response", models.JSONField(blank=True, default=dict)),
|
|
("created_at", models.DateTimeField(auto_now_add=True)),
|
|
("conversation", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name="messages", to="farm_ai_assistant.conversation")),
|
|
],
|
|
options={
|
|
"db_table": "farm_ai_messages",
|
|
"ordering": ["created_at", "id"],
|
|
},
|
|
),
|
|
]
|