# Generated by Django 4.1.3 on 2022-11-14 00:41

import django.db.models.deletion
import django.utils.timezone
from django.db import migrations, models

import activities.models.post_interaction
import stator.models


class Migration(migrations.Migration):

    dependencies = [
        ("users", "0002_identity_public_key_id"),
        ("activities", "0003_alter_post_object_uri"),
    ]

    operations = [
        migrations.RenameField(
            model_name="post",
            old_name="authored",
            new_name="published",
        ),
        migrations.AlterField(
            model_name="fanout",
            name="type",
            field=models.CharField(
                choices=[("post", "Post"), ("interaction", "Interaction")],
                max_length=100,
            ),
        ),
        migrations.AlterField(
            model_name="timelineevent",
            name="subject_post",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name="timeline_events",
                to="activities.post",
            ),
        ),
        migrations.CreateModel(
            name="PostInteraction",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("state_ready", models.BooleanField(default=True)),
                ("state_changed", models.DateTimeField(auto_now_add=True)),
                ("state_attempted", models.DateTimeField(blank=True, null=True)),
                ("state_locked_until", models.DateTimeField(blank=True, null=True)),
                (
                    "state",
                    stator.models.StateField(
                        choices=[("new", "new"), ("fanned_out", "fanned_out")],
                        default="new",
                        graph=activities.models.post_interaction.PostInteractionStates,
                        max_length=100,
                    ),
                ),
                (
                    "object_uri",
                    models.CharField(
                        blank=True, max_length=500, null=True, unique=True
                    ),
                ),
                (
                    "type",
                    models.CharField(
                        choices=[("like", "Like"), ("boost", "Boost")], max_length=100
                    ),
                ),
                ("published", models.DateTimeField(default=django.utils.timezone.now)),
                ("created", models.DateTimeField(auto_now_add=True)),
                ("updated", models.DateTimeField(auto_now=True)),
                (
                    "identity",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="interactions",
                        to="users.identity",
                    ),
                ),
                (
                    "post",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="interactions",
                        to="activities.post",
                    ),
                ),
            ],
            options={
                "index_together": {("type", "identity", "post")},
            },
        ),
        migrations.AddField(
            model_name="fanout",
            name="subject_post_interaction",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name="fan_outs",
                to="activities.postinteraction",
            ),
        ),
        migrations.AddField(
            model_name="timelineevent",
            name="subject_post_interaction",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name="timeline_events",
                to="activities.postinteraction",
            ),
        ),
    ]
