Files
GNX-WEB/gnx-react/backend/support/migrations/0001_initial.py
Iliyan Angelov d48c54e2c5 update
2025-10-07 22:10:27 +03:00

184 lines
11 KiB
Python

# Generated by Django 4.2.7 on 2025-10-07 15:42
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='SupportSettings',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('setting_name', models.CharField(max_length=100, unique=True)),
('setting_value', models.TextField()),
('description', models.TextField(blank=True)),
('is_active', models.BooleanField(default=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
],
options={
'verbose_name_plural': 'Support Settings',
},
),
migrations.CreateModel(
name='TicketCategory',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100, unique=True)),
('description', models.TextField(blank=True)),
('color', models.CharField(default='#667eea', help_text='Hex color code', max_length=7)),
('icon', models.CharField(default='fa-question-circle', help_text='FontAwesome icon class', max_length=50)),
('is_active', models.BooleanField(default=True)),
('display_order', models.PositiveIntegerField(default=0)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
],
options={
'verbose_name_plural': 'Ticket Categories',
'ordering': ['display_order', 'name'],
},
),
migrations.CreateModel(
name='TicketPriority',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=50, unique=True)),
('level', models.PositiveIntegerField(help_text='Lower number = higher priority', unique=True)),
('color', models.CharField(default='#667eea', help_text='Hex color code', max_length=7)),
('description', models.TextField(blank=True)),
('sla_hours', models.PositiveIntegerField(default=24, help_text='SLA response time in hours')),
('is_active', models.BooleanField(default=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
],
options={
'verbose_name_plural': 'Ticket Priorities',
'ordering': ['level'],
},
),
migrations.CreateModel(
name='TicketStatus',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=50, unique=True)),
('color', models.CharField(default='#667eea', help_text='Hex color code', max_length=7)),
('description', models.TextField(blank=True)),
('is_closed', models.BooleanField(default=False, help_text='Whether this status represents a closed ticket')),
('is_active', models.BooleanField(default=True)),
('display_order', models.PositiveIntegerField(default=0)),
('created_at', models.DateTimeField(auto_now_add=True)),
],
options={
'verbose_name_plural': 'Ticket Statuses',
'ordering': ['display_order', 'name'],
},
),
migrations.CreateModel(
name='SupportTicket',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('ticket_number', models.CharField(editable=False, max_length=20, unique=True)),
('title', models.CharField(max_length=200)),
('description', models.TextField()),
('ticket_type', models.CharField(choices=[('technical', 'Technical Issue'), ('billing', 'Billing Question'), ('feature_request', 'Feature Request'), ('bug_report', 'Bug Report'), ('general', 'General Inquiry'), ('account', 'Account Issue')], default='general', max_length=20)),
('user_name', models.CharField(max_length=100)),
('user_email', models.EmailField(max_length=254)),
('user_phone', models.CharField(blank=True, max_length=20)),
('company', models.CharField(blank=True, max_length=100)),
('assigned_at', models.DateTimeField(blank=True, null=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('closed_at', models.DateTimeField(blank=True, null=True)),
('last_activity', models.DateTimeField(auto_now=True)),
('first_response_at', models.DateTimeField(blank=True, null=True)),
('sla_deadline', models.DateTimeField(blank=True, null=True)),
('tags', models.CharField(blank=True, help_text='Comma-separated tags', max_length=500)),
('internal_notes', models.TextField(blank=True, help_text='Internal notes visible only to staff')),
('is_escalated', models.BooleanField(default=False)),
('escalation_reason', models.TextField(blank=True)),
('attachments', models.JSONField(blank=True, default=list, help_text='List of file paths')),
('assigned_to', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='assigned_tickets', to=settings.AUTH_USER_MODEL)),
('category', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='support.ticketcategory')),
('priority', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='support.ticketpriority')),
('status', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='support.ticketstatus')),
('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='support_tickets', to=settings.AUTH_USER_MODEL)),
],
options={
'ordering': ['-created_at'],
},
),
migrations.CreateModel(
name='TicketMessage',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('message_type', models.CharField(choices=[('user_message', 'User Message'), ('agent_response', 'Agent Response'), ('system_note', 'System Note'), ('status_change', 'Status Change'), ('assignment_change', 'Assignment Change'), ('escalation', 'Escalation')], default='user_message', max_length=20)),
('content', models.TextField()),
('author_name', models.CharField(blank=True, max_length=100)),
('author_email', models.EmailField(blank=True, max_length=254)),
('is_internal', models.BooleanField(default=False, help_text='Internal message not visible to user')),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('attachments', models.JSONField(blank=True, default=list, help_text='List of file paths')),
('is_read', models.BooleanField(default=False)),
('read_at', models.DateTimeField(blank=True, null=True)),
('author', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='ticket_messages', to=settings.AUTH_USER_MODEL)),
('read_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='read_messages', to=settings.AUTH_USER_MODEL)),
('ticket', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='messages', to='support.supportticket')),
],
options={
'ordering': ['created_at'],
'indexes': [models.Index(fields=['ticket', 'created_at'], name='support_tic_ticket__0cd9bd_idx'), models.Index(fields=['author'], name='support_tic_author__503d4b_idx'), models.Index(fields=['message_type'], name='support_tic_message_6220bd_idx')],
},
),
migrations.CreateModel(
name='TicketActivity',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('activity_type', models.CharField(choices=[('created', 'Ticket Created'), ('updated', 'Ticket Updated'), ('status_changed', 'Status Changed'), ('assigned', 'Ticket Assigned'), ('message_added', 'Message Added'), ('escalated', 'Ticket Escalated'), ('closed', 'Ticket Closed'), ('reopened', 'Ticket Reopened')], max_length=20)),
('description', models.TextField()),
('user_name', models.CharField(blank=True, max_length=100)),
('old_value', models.TextField(blank=True)),
('new_value', models.TextField(blank=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('ticket', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='activities', to='support.supportticket')),
('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='ticket_activities', to=settings.AUTH_USER_MODEL)),
],
options={
'ordering': ['-created_at'],
'indexes': [models.Index(fields=['ticket', 'created_at'], name='support_tic_ticket__4097ca_idx'), models.Index(fields=['activity_type'], name='support_tic_activit_9c98a0_idx')],
},
),
migrations.AddIndex(
model_name='supportticket',
index=models.Index(fields=['ticket_number'], name='support_sup_ticket__4a7d4b_idx'),
),
migrations.AddIndex(
model_name='supportticket',
index=models.Index(fields=['user_email'], name='support_sup_user_em_c518a8_idx'),
),
migrations.AddIndex(
model_name='supportticket',
index=models.Index(fields=['status'], name='support_sup_status__7b4480_idx'),
),
migrations.AddIndex(
model_name='supportticket',
index=models.Index(fields=['priority'], name='support_sup_priorit_5d48ff_idx'),
),
migrations.AddIndex(
model_name='supportticket',
index=models.Index(fields=['assigned_to'], name='support_sup_assigne_53b075_idx'),
),
migrations.AddIndex(
model_name='supportticket',
index=models.Index(fields=['created_at'], name='support_sup_created_83a137_idx'),
),
]