# Part 2 — mentorship models (NOT APPLIED YET)
# Review, then: python manage.py migrate mentorship

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('courses', '0006_projects_and_module_type'),
    ]

    operations = [
        migrations.CreateModel(
            name='Mentor',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('bio', models.TextField(blank=True)),
                ('expertise_tags', models.CharField(blank=True, help_text='Comma-separated tags, e.g. Laravel, SEO, Figma', max_length=400)),
                ('is_verified', models.BooleanField(default=False)),
                ('max_active_students', models.PositiveIntegerField(default=10, help_text='Cap on concurrent Learning Path mentees.')),
                ('is_active', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('categories', models.ManyToManyField(blank=True, help_text='Categories this mentor is vetted for.', related_name='mentors', to='courses.category')),
                ('courses', models.ManyToManyField(blank=True, help_text='Specific exam tracks this mentor supports.', related_name='mentors', to='courses.course')),
                ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='mentor_profile', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['user__full_name', 'user__username'],
            },
        ),
        migrations.CreateModel(
            name='MentorAssignment',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('status', models.CharField(choices=[('active', 'Active'), ('completed', 'Completed'), ('cancelled', 'Cancelled')], default='active', max_length=20)),
                ('weekly_cadence', models.BooleanField(default=True, help_text='Default: weekly mentoring sessions.')),
                ('notes', models.TextField(blank=True)),
                ('assigned_at', models.DateTimeField(auto_now_add=True)),
                ('ended_at', models.DateTimeField(blank=True, null=True)),
                ('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='mentor_assignments', to='courses.course')),
                ('mentor', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='assignments', to='mentorship.mentor')),
                ('student', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='mentor_assignments', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['-assigned_at'],
            },
        ),
        migrations.CreateModel(
            name='MentorSession',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('scheduled_at', models.DateTimeField()),
                ('duration_minutes', models.PositiveIntegerField(default=45)),
                ('meeting_link', models.URLField(blank=True, help_text='Zoom or Google Meet link.')),
                ('status', models.CharField(choices=[('scheduled', 'Scheduled'), ('completed', 'Completed'), ('no_show', 'No-show'), ('cancelled', 'Cancelled')], default='scheduled', max_length=20)),
                ('notes', models.TextField(blank=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('assignment', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='sessions', to='mentorship.mentorassignment')),
            ],
            options={
                'ordering': ['scheduled_at'],
            },
        ),
        migrations.AddConstraint(
            model_name='mentorassignment',
            constraint=models.UniqueConstraint(condition=models.Q(status='active'), fields=('student', 'course'), name='uniq_active_mentor_assignment_per_course'),
        ),
    ]
