# Generated by Django 5.2.5 on 2025-08-29 18:58

import django.db.models.deletion
import pgtrigger.compiler
import pgtrigger.migrations
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("contenttypes", "0002_remove_content_type_name"),
        ("moderation", "0002_remove_editsubmission_insert_insert_and_more"),
        ("pghistory", "0006_delete_aggregateevent"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="BulkOperation",
            fields=[
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "id",
                    models.CharField(max_length=50, primary_key=True, serialize=False),
                ),
                (
                    "operation_type",
                    models.CharField(
                        choices=[
                            ("UPDATE_PARKS", "Update Parks"),
                            ("UPDATE_RIDES", "Update Rides"),
                            ("IMPORT_DATA", "Import Data"),
                            ("EXPORT_DATA", "Export Data"),
                            ("RECALCULATE_STATS", "Recalculate Stats"),
                            ("MODERATE_CONTENT", "Moderate Content"),
                            ("USER_ACTIONS", "User Actions"),
                        ],
                        max_length=30,
                    ),
                ),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("PENDING", "Pending"),
                            ("RUNNING", "Running"),
                            ("COMPLETED", "Completed"),
                            ("FAILED", "Failed"),
                            ("CANCELLED", "Cancelled"),
                        ],
                        default="PENDING",
                        max_length=20,
                    ),
                ),
                (
                    "priority",
                    models.CharField(
                        choices=[
                            ("LOW", "Low"),
                            ("NORMAL", "Normal"),
                            ("HIGH", "High"),
                        ],
                        default="NORMAL",
                        max_length=10,
                    ),
                ),
                ("parameters", models.JSONField(default=dict)),
                ("results", models.JSONField(blank=True, null=True)),
                ("total_items", models.PositiveIntegerField(default=0)),
                ("processed_items", models.PositiveIntegerField(default=0)),
                ("failed_items", models.PositiveIntegerField(default=0)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("started_at", models.DateTimeField(blank=True, null=True)),
                ("completed_at", models.DateTimeField(blank=True, null=True)),
                (
                    "estimated_duration_minutes",
                    models.PositiveIntegerField(blank=True, null=True),
                ),
                ("can_cancel", models.BooleanField(default=True)),
                ("description", models.TextField(blank=True)),
                ("schedule_for", models.DateTimeField(blank=True, null=True)),
                (
                    "created_by",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="bulk_operations_created",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["-created_at"],
            },
        ),
        migrations.CreateModel(
            name="BulkOperationEvent",
            fields=[
                ("pgh_id", models.AutoField(primary_key=True, serialize=False)),
                ("pgh_created_at", models.DateTimeField(auto_now_add=True)),
                ("pgh_label", models.TextField(help_text="The event label.")),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("id", models.CharField(max_length=50, serialize=False)),
                (
                    "operation_type",
                    models.CharField(
                        choices=[
                            ("UPDATE_PARKS", "Update Parks"),
                            ("UPDATE_RIDES", "Update Rides"),
                            ("IMPORT_DATA", "Import Data"),
                            ("EXPORT_DATA", "Export Data"),
                            ("RECALCULATE_STATS", "Recalculate Stats"),
                            ("MODERATE_CONTENT", "Moderate Content"),
                            ("USER_ACTIONS", "User Actions"),
                        ],
                        max_length=30,
                    ),
                ),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("PENDING", "Pending"),
                            ("RUNNING", "Running"),
                            ("COMPLETED", "Completed"),
                            ("FAILED", "Failed"),
                            ("CANCELLED", "Cancelled"),
                        ],
                        default="PENDING",
                        max_length=20,
                    ),
                ),
                (
                    "priority",
                    models.CharField(
                        choices=[
                            ("LOW", "Low"),
                            ("NORMAL", "Normal"),
                            ("HIGH", "High"),
                        ],
                        default="NORMAL",
                        max_length=10,
                    ),
                ),
                ("parameters", models.JSONField(default=dict)),
                ("results", models.JSONField(blank=True, null=True)),
                ("total_items", models.PositiveIntegerField(default=0)),
                ("processed_items", models.PositiveIntegerField(default=0)),
                ("failed_items", models.PositiveIntegerField(default=0)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("started_at", models.DateTimeField(blank=True, null=True)),
                ("completed_at", models.DateTimeField(blank=True, null=True)),
                (
                    "estimated_duration_minutes",
                    models.PositiveIntegerField(blank=True, null=True),
                ),
                ("can_cancel", models.BooleanField(default=True)),
                ("description", models.TextField(blank=True)),
                ("schedule_for", models.DateTimeField(blank=True, null=True)),
                (
                    "created_by",
                    models.ForeignKey(
                        db_constraint=False,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        related_query_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "pgh_context",
                    models.ForeignKey(
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        to="pghistory.context",
                    ),
                ),
                (
                    "pgh_obj",
                    models.ForeignKey(
                        db_constraint=False,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="events",
                        to="moderation.bulkoperation",
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="ModerationAction",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "action_type",
                    models.CharField(
                        choices=[
                            ("WARNING", "Warning"),
                            ("CONTENT_REMOVAL", "Content Removal"),
                            ("CONTENT_EDIT", "Content Edit"),
                            ("USER_SUSPENSION", "User Suspension"),
                            ("USER_BAN", "User Ban"),
                            ("ACCOUNT_RESTRICTION", "Account Restriction"),
                        ],
                        max_length=30,
                    ),
                ),
                ("reason", models.CharField(max_length=255)),
                ("details", models.TextField()),
                ("duration_hours", models.PositiveIntegerField(blank=True, null=True)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("expires_at", models.DateTimeField(blank=True, null=True)),
                ("is_active", models.BooleanField(default=True)),
                (
                    "moderator",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="moderation_actions_taken",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "target_user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="moderation_actions_received",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["-created_at"],
            },
        ),
        migrations.CreateModel(
            name="ModerationQueue",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "item_type",
                    models.CharField(
                        choices=[
                            ("REPORT", "Report"),
                            ("FLAGGED_CONTENT", "Flagged Content"),
                            ("USER_APPEAL", "User Appeal"),
                            ("AUTOMATED_FLAG", "Automated Flag"),
                        ],
                        max_length=20,
                    ),
                ),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("PENDING", "Pending"),
                            ("IN_PROGRESS", "In Progress"),
                            ("COMPLETED", "Completed"),
                        ],
                        default="PENDING",
                        max_length=20,
                    ),
                ),
                (
                    "priority",
                    models.CharField(
                        choices=[
                            ("LOW", "Low"),
                            ("MEDIUM", "Medium"),
                            ("HIGH", "High"),
                            ("URGENT", "Urgent"),
                        ],
                        default="MEDIUM",
                        max_length=10,
                    ),
                ),
                ("title", models.CharField(max_length=255)),
                ("description", models.TextField()),
                ("entity_type", models.CharField(max_length=20)),
                ("entity_id", models.PositiveIntegerField()),
                ("entity_preview", models.JSONField(blank=True, default=dict)),
                (
                    "flagged_by",
                    models.CharField(
                        choices=[
                            ("USER_REPORT", "User Report"),
                            ("AUTOMATED_SYSTEM", "Automated System"),
                            ("MODERATOR_ESCALATION", "Moderator Escalation"),
                        ],
                        max_length=30,
                    ),
                ),
                ("assigned_at", models.DateTimeField(blank=True, null=True)),
                ("estimated_review_time", models.PositiveIntegerField(default=30)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("tags", models.JSONField(blank=True, default=list)),
                (
                    "assigned_to",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="assigned_queue_items",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "content_type",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="contenttypes.contenttype",
                    ),
                ),
            ],
            options={
                "ordering": ["-priority", "-created_at"],
            },
        ),
        migrations.CreateModel(
            name="ModerationReport",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "report_type",
                    models.CharField(
                        choices=[
                            ("INAPPROPRIATE_CONTENT", "Inappropriate Content"),
                            ("SPAM", "Spam"),
                            ("HARASSMENT", "Harassment"),
                            ("COPYRIGHT", "Copyright Violation"),
                            ("MISINFORMATION", "Misinformation"),
                            ("OTHER", "Other"),
                        ],
                        max_length=50,
                    ),
                ),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("PENDING", "Pending"),
                            ("UNDER_REVIEW", "Under Review"),
                            ("RESOLVED", "Resolved"),
                            ("DISMISSED", "Dismissed"),
                        ],
                        default="PENDING",
                        max_length=20,
                    ),
                ),
                (
                    "priority",
                    models.CharField(
                        choices=[
                            ("LOW", "Low"),
                            ("MEDIUM", "Medium"),
                            ("HIGH", "High"),
                            ("URGENT", "Urgent"),
                        ],
                        default="MEDIUM",
                        max_length=10,
                    ),
                ),
                ("reported_entity_type", models.CharField(max_length=20)),
                ("reported_entity_id", models.PositiveIntegerField()),
                ("reason", models.CharField(max_length=255)),
                ("description", models.TextField()),
                ("evidence_urls", models.JSONField(blank=True, default=list)),
                ("resolved_at", models.DateTimeField(blank=True, null=True)),
                ("resolution_notes", models.TextField(blank=True)),
                (
                    "resolution_action",
                    models.CharField(
                        blank=True,
                        choices=[
                            ("NO_ACTION", "No Action"),
                            ("CONTENT_REMOVED", "Content Removed"),
                            ("CONTENT_EDITED", "Content Edited"),
                            ("USER_WARNING", "User Warning"),
                            ("USER_SUSPENDED", "User Suspended"),
                            ("USER_BANNED", "User Banned"),
                        ],
                        max_length=20,
                        null=True,
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "assigned_moderator",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="assigned_moderation_reports",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "content_type",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="contenttypes.contenttype",
                    ),
                ),
                (
                    "reported_by",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="moderation_reports_made",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["-created_at"],
            },
        ),
        migrations.CreateModel(
            name="ModerationQueueEvent",
            fields=[
                ("pgh_id", models.AutoField(primary_key=True, serialize=False)),
                ("pgh_created_at", models.DateTimeField(auto_now_add=True)),
                ("pgh_label", models.TextField(help_text="The event label.")),
                ("id", models.BigIntegerField()),
                (
                    "item_type",
                    models.CharField(
                        choices=[
                            ("REPORT", "Report"),
                            ("FLAGGED_CONTENT", "Flagged Content"),
                            ("USER_APPEAL", "User Appeal"),
                            ("AUTOMATED_FLAG", "Automated Flag"),
                        ],
                        max_length=20,
                    ),
                ),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("PENDING", "Pending"),
                            ("IN_PROGRESS", "In Progress"),
                            ("COMPLETED", "Completed"),
                        ],
                        default="PENDING",
                        max_length=20,
                    ),
                ),
                (
                    "priority",
                    models.CharField(
                        choices=[
                            ("LOW", "Low"),
                            ("MEDIUM", "Medium"),
                            ("HIGH", "High"),
                            ("URGENT", "Urgent"),
                        ],
                        default="MEDIUM",
                        max_length=10,
                    ),
                ),
                ("title", models.CharField(max_length=255)),
                ("description", models.TextField()),
                ("entity_type", models.CharField(max_length=20)),
                ("entity_id", models.PositiveIntegerField()),
                ("entity_preview", models.JSONField(blank=True, default=dict)),
                (
                    "flagged_by",
                    models.CharField(
                        choices=[
                            ("USER_REPORT", "User Report"),
                            ("AUTOMATED_SYSTEM", "Automated System"),
                            ("MODERATOR_ESCALATION", "Moderator Escalation"),
                        ],
                        max_length=30,
                    ),
                ),
                ("assigned_at", models.DateTimeField(blank=True, null=True)),
                ("estimated_review_time", models.PositiveIntegerField(default=30)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("tags", models.JSONField(blank=True, default=list)),
                (
                    "assigned_to",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        related_query_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "content_type",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        related_query_name="+",
                        to="contenttypes.contenttype",
                    ),
                ),
                (
                    "pgh_context",
                    models.ForeignKey(
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        to="pghistory.context",
                    ),
                ),
                (
                    "pgh_obj",
                    models.ForeignKey(
                        db_constraint=False,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="events",
                        to="moderation.moderationqueue",
                    ),
                ),
                (
                    "related_report",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        related_query_name="+",
                        to="moderation.moderationreport",
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.AddField(
            model_name="moderationqueue",
            name="related_report",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name="queue_items",
                to="moderation.moderationreport",
            ),
        ),
        migrations.CreateModel(
            name="ModerationActionEvent",
            fields=[
                ("pgh_id", models.AutoField(primary_key=True, serialize=False)),
                ("pgh_created_at", models.DateTimeField(auto_now_add=True)),
                ("pgh_label", models.TextField(help_text="The event label.")),
                ("id", models.BigIntegerField()),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "action_type",
                    models.CharField(
                        choices=[
                            ("WARNING", "Warning"),
                            ("CONTENT_REMOVAL", "Content Removal"),
                            ("CONTENT_EDIT", "Content Edit"),
                            ("USER_SUSPENSION", "User Suspension"),
                            ("USER_BAN", "User Ban"),
                            ("ACCOUNT_RESTRICTION", "Account Restriction"),
                        ],
                        max_length=30,
                    ),
                ),
                ("reason", models.CharField(max_length=255)),
                ("details", models.TextField()),
                ("duration_hours", models.PositiveIntegerField(blank=True, null=True)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("expires_at", models.DateTimeField(blank=True, null=True)),
                ("is_active", models.BooleanField(default=True)),
                (
                    "moderator",
                    models.ForeignKey(
                        db_constraint=False,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        related_query_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "pgh_context",
                    models.ForeignKey(
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        to="pghistory.context",
                    ),
                ),
                (
                    "pgh_obj",
                    models.ForeignKey(
                        db_constraint=False,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="events",
                        to="moderation.moderationaction",
                    ),
                ),
                (
                    "target_user",
                    models.ForeignKey(
                        db_constraint=False,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        related_query_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "related_report",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        related_query_name="+",
                        to="moderation.moderationreport",
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.AddField(
            model_name="moderationaction",
            name="related_report",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="actions_taken",
                to="moderation.moderationreport",
            ),
        ),
        migrations.CreateModel(
            name="ModerationReportEvent",
            fields=[
                ("pgh_id", models.AutoField(primary_key=True, serialize=False)),
                ("pgh_created_at", models.DateTimeField(auto_now_add=True)),
                ("pgh_label", models.TextField(help_text="The event label.")),
                ("id", models.BigIntegerField()),
                (
                    "report_type",
                    models.CharField(
                        choices=[
                            ("INAPPROPRIATE_CONTENT", "Inappropriate Content"),
                            ("SPAM", "Spam"),
                            ("HARASSMENT", "Harassment"),
                            ("COPYRIGHT", "Copyright Violation"),
                            ("MISINFORMATION", "Misinformation"),
                            ("OTHER", "Other"),
                        ],
                        max_length=50,
                    ),
                ),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("PENDING", "Pending"),
                            ("UNDER_REVIEW", "Under Review"),
                            ("RESOLVED", "Resolved"),
                            ("DISMISSED", "Dismissed"),
                        ],
                        default="PENDING",
                        max_length=20,
                    ),
                ),
                (
                    "priority",
                    models.CharField(
                        choices=[
                            ("LOW", "Low"),
                            ("MEDIUM", "Medium"),
                            ("HIGH", "High"),
                            ("URGENT", "Urgent"),
                        ],
                        default="MEDIUM",
                        max_length=10,
                    ),
                ),
                ("reported_entity_type", models.CharField(max_length=20)),
                ("reported_entity_id", models.PositiveIntegerField()),
                ("reason", models.CharField(max_length=255)),
                ("description", models.TextField()),
                ("evidence_urls", models.JSONField(blank=True, default=list)),
                ("resolved_at", models.DateTimeField(blank=True, null=True)),
                ("resolution_notes", models.TextField(blank=True)),
                (
                    "resolution_action",
                    models.CharField(
                        blank=True,
                        choices=[
                            ("NO_ACTION", "No Action"),
                            ("CONTENT_REMOVED", "Content Removed"),
                            ("CONTENT_EDITED", "Content Edited"),
                            ("USER_WARNING", "User Warning"),
                            ("USER_SUSPENDED", "User Suspended"),
                            ("USER_BANNED", "User Banned"),
                        ],
                        max_length=20,
                        null=True,
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "assigned_moderator",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        related_query_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "content_type",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        related_query_name="+",
                        to="contenttypes.contenttype",
                    ),
                ),
                (
                    "pgh_context",
                    models.ForeignKey(
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        to="pghistory.context",
                    ),
                ),
                (
                    "pgh_obj",
                    models.ForeignKey(
                        db_constraint=False,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="events",
                        to="moderation.moderationreport",
                    ),
                ),
                (
                    "reported_by",
                    models.ForeignKey(
                        db_constraint=False,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        related_query_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.AddIndex(
            model_name="bulkoperation",
            index=models.Index(fields=["status", "priority"], name="moderation__status_f11ee8_idx"),
        ),
        migrations.AddIndex(
            model_name="bulkoperation",
            index=models.Index(fields=["created_by"], name="moderation__created_4fe5d2_idx"),
        ),
        migrations.AddIndex(
            model_name="bulkoperation",
            index=models.Index(fields=["operation_type"], name="moderation__operati_bc84d9_idx"),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="bulkoperation",
            trigger=pgtrigger.compiler.Trigger(
                name="insert_insert",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    func='INSERT INTO "moderation_bulkoperationevent" ("can_cancel", "completed_at", "created_at", "created_by_id", "description", "estimated_duration_minutes", "failed_items", "id", "operation_type", "parameters", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "priority", "processed_items", "results", "schedule_for", "started_at", "status", "total_items", "updated_at") VALUES (NEW."can_cancel", NEW."completed_at", NEW."created_at", NEW."created_by_id", NEW."description", NEW."estimated_duration_minutes", NEW."failed_items", NEW."id", NEW."operation_type", NEW."parameters", _pgh_attach_context(), NOW(), \'insert\', NEW."id", NEW."priority", NEW."processed_items", NEW."results", NEW."schedule_for", NEW."started_at", NEW."status", NEW."total_items", NEW."updated_at"); RETURN NULL;',
                    hash="6b77f43e19a6d3862cf52ccb8ff5cce33f98c12d",
                    operation="INSERT",
                    pgid="pgtrigger_insert_insert_5e87c",
                    table="moderation_bulkoperation",
                    when="AFTER",
                ),
            ),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="bulkoperation",
            trigger=pgtrigger.compiler.Trigger(
                name="update_update",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    condition="WHEN (OLD.* IS DISTINCT FROM NEW.*)",
                    func='INSERT INTO "moderation_bulkoperationevent" ("can_cancel", "completed_at", "created_at", "created_by_id", "description", "estimated_duration_minutes", "failed_items", "id", "operation_type", "parameters", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "priority", "processed_items", "results", "schedule_for", "started_at", "status", "total_items", "updated_at") VALUES (NEW."can_cancel", NEW."completed_at", NEW."created_at", NEW."created_by_id", NEW."description", NEW."estimated_duration_minutes", NEW."failed_items", NEW."id", NEW."operation_type", NEW."parameters", _pgh_attach_context(), NOW(), \'update\', NEW."id", NEW."priority", NEW."processed_items", NEW."results", NEW."schedule_for", NEW."started_at", NEW."status", NEW."total_items", NEW."updated_at"); RETURN NULL;',
                    hash="d652ed05c30c256957625d4cec89a30cf30bbcda",
                    operation="UPDATE",
                    pgid="pgtrigger_update_update_5b85c",
                    table="moderation_bulkoperation",
                    when="AFTER",
                ),
            ),
        ),
        migrations.AddIndex(
            model_name="moderationreport",
            index=models.Index(fields=["status", "priority"], name="moderation__status_6aa18c_idx"),
        ),
        migrations.AddIndex(
            model_name="moderationreport",
            index=models.Index(
                fields=["reported_entity_type", "reported_entity_id"],
                name="moderation__reporte_04923f_idx",
            ),
        ),
        migrations.AddIndex(
            model_name="moderationreport",
            index=models.Index(fields=["assigned_moderator"], name="moderation__assigne_c43cdf_idx"),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="moderationreport",
            trigger=pgtrigger.compiler.Trigger(
                name="insert_insert",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    func='INSERT INTO "moderation_moderationreportevent" ("assigned_moderator_id", "content_type_id", "created_at", "description", "evidence_urls", "id", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "priority", "reason", "report_type", "reported_by_id", "reported_entity_id", "reported_entity_type", "resolution_action", "resolution_notes", "resolved_at", "status", "updated_at") VALUES (NEW."assigned_moderator_id", NEW."content_type_id", NEW."created_at", NEW."description", NEW."evidence_urls", NEW."id", _pgh_attach_context(), NOW(), \'insert\', NEW."id", NEW."priority", NEW."reason", NEW."report_type", NEW."reported_by_id", NEW."reported_entity_id", NEW."reported_entity_type", NEW."resolution_action", NEW."resolution_notes", NEW."resolved_at", NEW."status", NEW."updated_at"); RETURN NULL;',
                    hash="913644a52cf757b26e9c99eefd68ca6c23777cff",
                    operation="INSERT",
                    pgid="pgtrigger_insert_insert_bb855",
                    table="moderation_moderationreport",
                    when="AFTER",
                ),
            ),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="moderationreport",
            trigger=pgtrigger.compiler.Trigger(
                name="update_update",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    condition="WHEN (OLD.* IS DISTINCT FROM NEW.*)",
                    func='INSERT INTO "moderation_moderationreportevent" ("assigned_moderator_id", "content_type_id", "created_at", "description", "evidence_urls", "id", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "priority", "reason", "report_type", "reported_by_id", "reported_entity_id", "reported_entity_type", "resolution_action", "resolution_notes", "resolved_at", "status", "updated_at") VALUES (NEW."assigned_moderator_id", NEW."content_type_id", NEW."created_at", NEW."description", NEW."evidence_urls", NEW."id", _pgh_attach_context(), NOW(), \'update\', NEW."id", NEW."priority", NEW."reason", NEW."report_type", NEW."reported_by_id", NEW."reported_entity_id", NEW."reported_entity_type", NEW."resolution_action", NEW."resolution_notes", NEW."resolved_at", NEW."status", NEW."updated_at"); RETURN NULL;',
                    hash="e31bdc9823aa3a8da9f0448949fbc76c46bc7bf3",
                    operation="UPDATE",
                    pgid="pgtrigger_update_update_55763",
                    table="moderation_moderationreport",
                    when="AFTER",
                ),
            ),
        ),
        migrations.AddIndex(
            model_name="moderationqueue",
            index=models.Index(fields=["status", "priority"], name="moderation__status_6f2a75_idx"),
        ),
        migrations.AddIndex(
            model_name="moderationqueue",
            index=models.Index(
                fields=["entity_type", "entity_id"],
                name="moderation__entity__7c66ff_idx",
            ),
        ),
        migrations.AddIndex(
            model_name="moderationqueue",
            index=models.Index(fields=["assigned_to"], name="moderation__assigne_2fc958_idx"),
        ),
        migrations.AddIndex(
            model_name="moderationqueue",
            index=models.Index(fields=["flagged_by"], name="moderation__flagged_169834_idx"),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="moderationqueue",
            trigger=pgtrigger.compiler.Trigger(
                name="insert_insert",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    func='INSERT INTO "moderation_moderationqueueevent" ("assigned_at", "assigned_to_id", "content_type_id", "created_at", "description", "entity_id", "entity_preview", "entity_type", "estimated_review_time", "flagged_by", "id", "item_type", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "priority", "related_report_id", "status", "tags", "title", "updated_at") VALUES (NEW."assigned_at", NEW."assigned_to_id", NEW."content_type_id", NEW."created_at", NEW."description", NEW."entity_id", NEW."entity_preview", NEW."entity_type", NEW."estimated_review_time", NEW."flagged_by", NEW."id", NEW."item_type", _pgh_attach_context(), NOW(), \'insert\', NEW."id", NEW."priority", NEW."related_report_id", NEW."status", NEW."tags", NEW."title", NEW."updated_at"); RETURN NULL;',
                    hash="a6838ea3f58d556d3fe424e19a34e02416f05a72",
                    operation="INSERT",
                    pgid="pgtrigger_insert_insert_cf9cb",
                    table="moderation_moderationqueue",
                    when="AFTER",
                ),
            ),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="moderationqueue",
            trigger=pgtrigger.compiler.Trigger(
                name="update_update",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    condition="WHEN (OLD.* IS DISTINCT FROM NEW.*)",
                    func='INSERT INTO "moderation_moderationqueueevent" ("assigned_at", "assigned_to_id", "content_type_id", "created_at", "description", "entity_id", "entity_preview", "entity_type", "estimated_review_time", "flagged_by", "id", "item_type", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "priority", "related_report_id", "status", "tags", "title", "updated_at") VALUES (NEW."assigned_at", NEW."assigned_to_id", NEW."content_type_id", NEW."created_at", NEW."description", NEW."entity_id", NEW."entity_preview", NEW."entity_type", NEW."estimated_review_time", NEW."flagged_by", NEW."id", NEW."item_type", _pgh_attach_context(), NOW(), \'update\', NEW."id", NEW."priority", NEW."related_report_id", NEW."status", NEW."tags", NEW."title", NEW."updated_at"); RETURN NULL;',
                    hash="fa7a6c0da3f1acfb85d573ac11d7f3e2dbdf2373",
                    operation="UPDATE",
                    pgid="pgtrigger_update_update_3b3aa",
                    table="moderation_moderationqueue",
                    when="AFTER",
                ),
            ),
        ),
        migrations.AddIndex(
            model_name="moderationaction",
            index=models.Index(
                fields=["target_user", "is_active"],
                name="moderation__target__fc8ec5_idx",
            ),
        ),
        migrations.AddIndex(
            model_name="moderationaction",
            index=models.Index(
                fields=["action_type", "is_active"],
                name="moderation__action__7d7882_idx",
            ),
        ),
        migrations.AddIndex(
            model_name="moderationaction",
            index=models.Index(fields=["expires_at"], name="moderation__expires_963efb_idx"),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="moderationaction",
            trigger=pgtrigger.compiler.Trigger(
                name="insert_insert",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    func='INSERT INTO "moderation_moderationactionevent" ("action_type", "created_at", "details", "duration_hours", "expires_at", "id", "is_active", "moderator_id", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "reason", "related_report_id", "target_user_id", "updated_at") VALUES (NEW."action_type", NEW."created_at", NEW."details", NEW."duration_hours", NEW."expires_at", NEW."id", NEW."is_active", NEW."moderator_id", _pgh_attach_context(), NOW(), \'insert\', NEW."id", NEW."reason", NEW."related_report_id", NEW."target_user_id", NEW."updated_at"); RETURN NULL;',
                    hash="d633c697d9068e2dc4a4e657b9af1c1247ee6e8f",
                    operation="INSERT",
                    pgid="pgtrigger_insert_insert_ec7c5",
                    table="moderation_moderationaction",
                    when="AFTER",
                ),
            ),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="moderationaction",
            trigger=pgtrigger.compiler.Trigger(
                name="update_update",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    condition="WHEN (OLD.* IS DISTINCT FROM NEW.*)",
                    func='INSERT INTO "moderation_moderationactionevent" ("action_type", "created_at", "details", "duration_hours", "expires_at", "id", "is_active", "moderator_id", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "reason", "related_report_id", "target_user_id", "updated_at") VALUES (NEW."action_type", NEW."created_at", NEW."details", NEW."duration_hours", NEW."expires_at", NEW."id", NEW."is_active", NEW."moderator_id", _pgh_attach_context(), NOW(), \'update\', NEW."id", NEW."reason", NEW."related_report_id", NEW."target_user_id", NEW."updated_at"); RETURN NULL;',
                    hash="58d5350f7ee0230033c491b6cbed1f356459c9da",
                    operation="UPDATE",
                    pgid="pgtrigger_update_update_2aec7",
                    table="moderation_moderationaction",
                    when="AFTER",
                ),
            ),
        ),
    ]
