# Generated by Django 5.2.13 on 2026-04-24 10:29

import apps.core.storage.paths
import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ("alumni_profiles", "0001_initial"),
    ]

    operations = [
        migrations.CreateModel(
            name="ImpactSnapshot",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                ("period_label", models.CharField(max_length=16, unique=True)),
                ("generated_at", models.DateTimeField(auto_now=True)),
                ("total_alumni", models.PositiveIntegerField(default=0)),
                ("active_mentorships", models.PositiveIntegerField(default=0)),
                ("total_publications", models.PositiveIntegerField(default=0)),
                ("total_citations", models.PositiveIntegerField(default=0)),
                (
                    "funding_secured_usd",
                    models.DecimalField(decimal_places=2, default=0, max_digits=18),
                ),
                ("breakdown", models.JSONField(blank=True, default=dict)),
            ],
            options={
                "ordering": ["-period_label"],
            },
        ),
        migrations.CreateModel(
            name="OrcidSyncLog",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                ("orcid_id", models.CharField(max_length=19)),
                ("last_attempt_at", models.DateTimeField(blank=True, null=True)),
                ("last_success_at", models.DateTimeField(blank=True, null=True)),
                ("last_error", models.TextField(blank=True)),
                ("consecutive_failures", models.PositiveIntegerField(default=0)),
                ("works_imported_count", models.PositiveIntegerField(default=0)),
                (
                    "profile",
                    models.OneToOneField(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="orcid_sync_log",
                        to="alumni_profiles.alumniprofile",
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="CareerMilestone",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "milestone_type",
                    models.CharField(
                        choices=[
                            ("promotion", "Promotion"),
                            ("new_job", "New job"),
                            ("award", "Award"),
                            ("publication", "Publication"),
                            ("grant", "Grant"),
                            ("patent", "Patent"),
                            ("leadership", "Leadership role"),
                            ("speaking", "Speaking engagement"),
                            ("graduation", "Graduation"),
                            ("recognition", "Recognition"),
                            ("other", "Other"),
                        ],
                        default="other",
                        max_length=24,
                    ),
                ),
                ("title", models.CharField(max_length=255)),
                ("description", models.TextField(blank=True)),
                ("occurred_on", models.DateField()),
                ("url", models.URLField(blank=True)),
                (
                    "evidence_file",
                    models.FileField(
                        blank=True,
                        null=True,
                        upload_to=apps.core.storage.paths.upload_to_alumni_certificates,
                    ),
                ),
                (
                    "visibility",
                    models.CharField(
                        choices=[
                            ("public", "Public"),
                            ("network", "Alumni network only"),
                            ("private", "Private"),
                        ],
                        default="public",
                        max_length=16,
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                (
                    "profile",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="milestones",
                        to="alumni_profiles.alumniprofile",
                    ),
                ),
            ],
            options={
                "ordering": ["-occurred_on"],
                "indexes": [
                    models.Index(
                        fields=["profile", "occurred_on"], name="alumni_trac_profile_b2e095_idx"
                    )
                ],
            },
        ),
        migrations.CreateModel(
            name="ImpactRecord",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "metric",
                    models.CharField(
                        choices=[
                            ("citations", "Citations"),
                            ("funding_secured_usd", "Funding secured (USD)"),
                            ("jobs_created", "Jobs created"),
                            ("students_supervised", "Students supervised"),
                            ("policies_influenced", "Policies influenced"),
                            ("media_mentions", "Media mentions"),
                        ],
                        max_length=32,
                    ),
                ),
                ("value", models.DecimalField(decimal_places=2, max_digits=16)),
                (
                    "period_label",
                    models.CharField(
                        help_text="Reporting period, e.g. '2026' or '2026-Q1'.", max_length=16
                    ),
                ),
                (
                    "source",
                    models.CharField(
                        choices=[
                            ("self", "Self-reported"),
                            ("auto", "Automated aggregation"),
                            ("orcid", "Synced from ORCID"),
                        ],
                        default="self",
                        max_length=16,
                    ),
                ),
                ("recorded_at", models.DateTimeField(auto_now_add=True)),
                (
                    "profile",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="impact_records",
                        to="alumni_profiles.alumniprofile",
                    ),
                ),
            ],
            options={
                "ordering": ["-period_label", "metric"],
                "constraints": [
                    models.UniqueConstraint(
                        fields=("profile", "metric", "period_label"),
                        name="uniq_impact_per_profile_metric_period",
                    )
                ],
            },
        ),
        migrations.CreateModel(
            name="ResearchOutput",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                ("put_code", models.CharField(help_text="ORCID work put-code", max_length=32)),
                ("title", models.CharField(max_length=500)),
                (
                    "publication_type",
                    models.CharField(
                        choices=[
                            ("journal-article", "Journal article"),
                            ("book", "Book"),
                            ("book-chapter", "Book chapter"),
                            ("conference-paper", "Conference paper"),
                            ("preprint", "Preprint"),
                            ("report", "Report"),
                            ("other", "Other"),
                        ],
                        default="other",
                        max_length=32,
                    ),
                ),
                ("doi", models.CharField(blank=True, max_length=128)),
                ("year", models.PositiveSmallIntegerField(blank=True, null=True)),
                ("payload", models.JSONField(blank=True, default=dict)),
                ("last_synced_at", models.DateTimeField(auto_now=True)),
                (
                    "profile",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="research_outputs",
                        to="alumni_profiles.alumniprofile",
                    ),
                ),
            ],
            options={
                "ordering": ["-year", "title"],
                "constraints": [
                    models.UniqueConstraint(
                        fields=("profile", "put_code"),
                        name="uniq_research_output_per_profile_putcode",
                    )
                ],
            },
        ),
    ]
