# Generated by Django 5.2.4 on 2025-07-31 00:21

import django.db.models.deletion
import uuid
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('utils', '0002_auditlog'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='SystemSetting',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('key', models.CharField(max_length=50, unique=True)),
                ('value', models.TextField(default='')),
                ('category', models.CharField(choices=[('system', 'System'), ('loan', 'Loan'), ('notification', 'Notification'), ('document', 'Document')], default='system', max_length=20)),
                ('description', models.TextField(blank=True, null=True)),
                ('is_public', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
            ],
            options={
                'ordering': ['category', 'key'],
            },
        ),
        migrations.CreateModel(
            name='Document',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(default='Untitled Document', max_length=255)),
                ('file', models.FileField(upload_to='documents/')),
                ('document_type', models.CharField(choices=[('loan_agreement', 'Loan Agreement'), ('id_document', 'ID Document'), ('selfie', 'Selfie Photo'), ('utility_bill', 'Utility Bill'), ('bank_statement', 'Bank Statement'), ('business_license', 'Business License'), ('tax_return', 'Tax Return'), ('payslip', 'Payslip'), ('contract', 'Contract'), ('other', 'Other')], default='other', max_length=50)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('description', models.TextField(blank=True, null=True)),
                ('thumbnail', models.ImageField(blank=True, null=True, upload_to='documents/thumbnails/')),
                ('file_size', models.PositiveIntegerField(default=0)),
                ('mime_type', models.CharField(blank=True, max_length=100)),
                ('is_public', models.BooleanField(default=False)),
                ('uploaded_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='DocumentShare',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('shared_at', models.DateTimeField(auto_now_add=True)),
                ('message', models.TextField(blank=True, null=True)),
                ('is_read', models.BooleanField(default=False)),
                ('document', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='utils.document')),
                ('shared_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='documents_shared', to=settings.AUTH_USER_MODEL)),
                ('shared_with', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['-shared_at'],
                'unique_together': {('document', 'shared_with')},
            },
        ),
        migrations.AddField(
            model_name='document',
            name='shared_with',
            field=models.ManyToManyField(related_name='shared_documents', through='utils.DocumentShare', through_fields=('document', 'shared_with'), to=settings.AUTH_USER_MODEL),
        ),
        migrations.CreateModel(
            name='DocumentTag',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=50, unique=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('created_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['name'],
            },
        ),
        migrations.AddField(
            model_name='document',
            name='tags',
            field=models.ManyToManyField(blank=True, to='utils.documenttag'),
        ),
        migrations.CreateModel(
            name='Notification',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('notification_type', models.CharField(choices=[('loan_approved', 'Loan Approved'), ('loan_rejected', 'Loan Rejected'), ('payment_due', 'Payment Due'), ('payment_received', 'Payment Received'), ('document_uploaded', 'Document Uploaded'), ('document_rejected', 'Document Rejected'), ('loan_overdue', 'Loan Overdue'), ('credit_score_update', 'Credit Score Update'), ('system_maintenance', 'System Maintenance'), ('security_alert', 'Security Alert'), ('profile_update', 'Profile Update'), ('new_feature', 'New Feature')], default='system_maintenance', max_length=50)),
                ('title', models.CharField(max_length=200)),
                ('message', models.TextField()),
                ('priority', models.CharField(choices=[('low', 'Low'), ('medium', 'Medium'), ('high', 'High'), ('urgent', 'Urgent')], default='medium', max_length=20)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('read_at', models.DateTimeField(blank=True, null=True)),
                ('action_url', models.CharField(blank=True, max_length=200, null=True)),
                ('expires_at', models.DateTimeField(blank=True, null=True)),
                ('icon', models.CharField(default='fa-bell', max_length=50)),
                ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='system_notifications', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['-created_at'],
                'indexes': [models.Index(fields=['user', '-created_at'], name='utils_notif_user_id_36dc1c_idx'), models.Index(fields=['notification_type'], name='utils_notif_notific_d43fdf_idx'), models.Index(fields=['read_at'], name='utils_notif_read_at_52948b_idx')],
            },
        ),
    ]
