# Generated by Django 4.2.4 on 2023-08-25 18:50

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


class Migration(migrations.Migration):

    dependencies = [
        ("takahe", "0001_initial"),
        ("journal", "0015_use_identity_support_remote_piece"),
    ]

    operations = [
        migrations.CreateModel(
            name="PiecePost",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "piece",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, to="journal.piece"
                    ),
                ),
                (
                    "post",
                    models.ForeignKey(
                        db_constraint=False,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="takahe.post",
                    ),
                ),
            ],
        ),
        migrations.AddField(
            model_name="piece",
            name="posts",
            field=models.ManyToManyField(
                related_name="pieces", through="journal.PiecePost", to="takahe.post"
            ),
        ),
        migrations.AddConstraint(
            model_name="piecepost",
            constraint=models.UniqueConstraint(
                fields=("piece", "post"), name="unique_piece_post"
            ),
        ),
    ]
