|
|
|
|
| from django.conf import settings
|
| from django.db import migrations, models
|
| import django.db.models.deletion
|
| import pgvector.django.vector
|
| import uuid
|
|
|
|
|
| class Migration(migrations.Migration):
|
|
|
| initial = True
|
|
|
| dependencies = [
|
| ('Property', '0063_alter_property_amenties'),
|
| migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
| ]
|
|
|
| operations = [
|
| migrations.CreateModel(
|
| name='AgencyAutoChatSetting',
|
| fields=[
|
| ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
| ('is_enabled', models.BooleanField(default=False)),
|
| ('delay_seconds', models.IntegerField(default=30, help_text='Seconds to wait before AI replies')),
|
| ('confidence_threshold', models.FloatField(default=0.6, help_text='Minimum similarity score (0-1)')),
|
| ('created_at', models.DateTimeField(auto_now_add=True)),
|
| ('updated_at', models.DateTimeField(auto_now=True)),
|
| ],
|
| ),
|
| migrations.CreateModel(
|
| name='GlobalQA',
|
| fields=[
|
| ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
| ('question', models.TextField(unique=True)),
|
| ('answer', models.TextField()),
|
| ('question_embedding', pgvector.django.vector.VectorField(dimensions=384)),
|
| ('language', models.CharField(choices=[('en', 'English'), ('ur', 'Roman Urdu'), ('both', 'Both')], default='both', max_length=20)),
|
| ('is_active', models.BooleanField(default=True)),
|
| ('priority', models.IntegerField(default=0)),
|
| ('created_at', models.DateTimeField(auto_now_add=True)),
|
| ],
|
| options={
|
| 'ordering': ['-priority', 'question'],
|
| },
|
| ),
|
| migrations.CreateModel(
|
| name='MasterQuestion',
|
| fields=[
|
| ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
| ('question', models.TextField(unique=True)),
|
| ('is_active', models.BooleanField(default=True)),
|
| ('order', models.IntegerField(default=0)),
|
| ('created_at', models.DateTimeField(auto_now_add=True)),
|
| ],
|
| options={
|
| 'ordering': ['order'],
|
| },
|
| ),
|
| migrations.CreateModel(
|
| name='PropertyQA',
|
| fields=[
|
| ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
| ('answer', models.TextField()),
|
| ('question_embedding', pgvector.django.vector.VectorField(dimensions=384)),
|
| ('is_active', models.BooleanField(default=True)),
|
| ('created_at', models.DateTimeField(auto_now_add=True)),
|
| ('updated_at', models.DateTimeField(auto_now=True)),
|
| ('agency', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='property_qa_answers', to=settings.AUTH_USER_MODEL)),
|
| ('master_question', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='ai_chatbot.masterquestion')),
|
| ('property', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='ai_qa', to='Property.property')),
|
| ],
|
| ),
|
| migrations.CreateModel(
|
| name='PropertyCustomQA',
|
| fields=[
|
| ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
| ('question', models.TextField()),
|
| ('answer', models.TextField()),
|
| ('question_embedding', pgvector.django.vector.VectorField(dimensions=384)),
|
| ('order', models.IntegerField(default=0)),
|
| ('is_active', models.BooleanField(default=True)),
|
| ('created_at', models.DateTimeField(auto_now_add=True)),
|
| ('updated_at', models.DateTimeField(auto_now=True)),
|
| ('agency', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='property_custom_qa', to=settings.AUTH_USER_MODEL)),
|
| ('property', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='custom_qa', to='Property.property')),
|
| ],
|
| options={
|
| 'ordering': ['order'],
|
| },
|
| ),
|
| migrations.CreateModel(
|
| name='PropertyAutoChatState',
|
| fields=[
|
| ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
| ('is_auto_chat_enabled', models.BooleanField(default=False)),
|
| ('last_auto_reply_at', models.DateTimeField(blank=True, null=True)),
|
| ('total_auto_replies', models.IntegerField(default=0)),
|
| ('last_agency_reply_at', models.DateTimeField(blank=True, null=True)),
|
| ('property', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='auto_chat_state', to='Property.property')),
|
| ],
|
| ),
|
| migrations.AddIndex(
|
| model_name='masterquestion',
|
| index=models.Index(fields=['is_active', 'order'], name='ai_chatbot__is_acti_4e4a3d_idx'),
|
| ),
|
| migrations.AddIndex(
|
| model_name='globalqa',
|
| index=models.Index(fields=['is_active', '-priority'], name='ai_chatbot__is_acti_fa63b9_idx'),
|
| ),
|
| migrations.AddIndex(
|
| model_name='globalqa',
|
| index=models.Index(fields=['language', 'is_active'], name='ai_chatbot__languag_9d512a_idx'),
|
| ),
|
| migrations.AddField(
|
| model_name='agencyautochatsetting',
|
| name='agency',
|
| field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='auto_chat_setting', to=settings.AUTH_USER_MODEL),
|
| ),
|
| migrations.AddIndex(
|
| model_name='propertyqa',
|
| index=models.Index(fields=['property', 'is_active'], name='ai_chatbot__propert_d93b25_idx'),
|
| ),
|
| migrations.AddIndex(
|
| model_name='propertyqa',
|
| index=models.Index(fields=['agency', 'is_active'], name='ai_chatbot__agency__41090d_idx'),
|
| ),
|
| migrations.AddIndex(
|
| model_name='propertyqa',
|
| index=models.Index(fields=['master_question', 'is_active'], name='ai_chatbot__master__144853_idx'),
|
| ),
|
| migrations.AlterUniqueTogether(
|
| name='propertyqa',
|
| unique_together={('property', 'master_question')},
|
| ),
|
| migrations.AddIndex(
|
| model_name='propertycustomqa',
|
| index=models.Index(fields=['property', 'is_active'], name='ai_chatbot__propert_e9a86b_idx'),
|
| ),
|
| migrations.AddIndex(
|
| model_name='propertycustomqa',
|
| index=models.Index(fields=['agency', 'is_active'], name='ai_chatbot__agency__fdf146_idx'),
|
| ),
|
| migrations.AddConstraint(
|
| model_name='propertycustomqa',
|
| constraint=models.UniqueConstraint(fields=('property', 'order'), name='unique_order_per_property'),
|
| ),
|
| migrations.AddIndex(
|
| model_name='propertyautochatstate',
|
| index=models.Index(fields=['is_auto_chat_enabled'], name='ai_chatbot__is_auto_1f624d_idx'),
|
| ),
|
| migrations.AddIndex(
|
| model_name='propertyautochatstate',
|
| index=models.Index(fields=['property', 'is_auto_chat_enabled'], name='ai_chatbot__propert_697127_idx'),
|
| ),
|
| migrations.AddIndex(
|
| model_name='agencyautochatsetting',
|
| index=models.Index(fields=['is_enabled'], name='ai_chatbot__is_enab_7f8ec6_idx'),
|
| ),
|
| ]
|
|
|