# Generated by Django 4.2.8 on 2023-12-27 20:09

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


class Migration(migrations.Migration):
    dependencies = [
        ("users", "0017_mastodon_site_username_bd2db5_idx"),
        ("journal", "0020_shelflogentry_unique_shelf_log_entry"),
    ]

    operations = [
        migrations.CreateModel(
            name="PieceInteraction",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("target_type", models.CharField(max_length=50)),
                ("interaction_type", models.CharField(max_length=50)),
                (
                    "created_time",
                    models.DateTimeField(default=django.utils.timezone.now),
                ),
                (
                    "identity",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="interactions",
                        to="users.apidentity",
                    ),
                ),
                (
                    "target",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="interactions",
                        to="journal.piece",
                    ),
                ),
            ],
            options={
                "indexes": [
                    models.Index(
                        fields=["identity", "interaction_type", "created_time"],
                        name="journal_pie_identit_bd12d3_idx",
                    ),
                    models.Index(
                        fields=["target", "interaction_type", "created_time"],
                        name="journal_pie_target__f943ca_idx",
                    ),
                ],
            },
        ),
        migrations.AddConstraint(
            model_name="pieceinteraction",
            constraint=models.UniqueConstraint(
                fields=("identity", "interaction_type", "target"),
                name="unique_interaction",
            ),
        ),
    ]
