# Generated by Django 5.1.2 on 2024-10-19 10:14

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="AnnouncementCategory",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "created_at",
                    models.DateTimeField(
                        db_comment="Timestamp for when the record was created.",
                        default=django.utils.timezone.now,
                        help_text="The time when the record was created.",
                        verbose_name="Created at",
                    ),
                ),
                (
                    "updated_at",
                    models.DateTimeField(
                        auto_now=True,
                        db_comment="Timestamp for when the record was last updated.",
                        help_text="The time when the record was last updated.",
                        verbose_name="Updated at",
                    ),
                ),
                (
                    "name",
                    models.CharField(
                        db_comment="The name of the announcement category, such as Conference or Webinar.",
                        help_text="The name of the announcement category.",
                        max_length=100,
                        unique=True,
                        verbose_name="Category Name",
                    ),
                ),
                (
                    "description",
                    models.TextField(
                        blank=True,
                        db_comment="Optional description to provide more details about the category.",
                        help_text="A brief description of the announcement category.",
                        null=True,
                        verbose_name="Description",
                    ),
                ),
            ],
            options={
                "verbose_name": "Announcement Category",
                "verbose_name_plural": "Announcement Categories",
                "db_table": "announcement_categories",
            },
        ),
        migrations.CreateModel(
            name="Audience",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "created_at",
                    models.DateTimeField(
                        db_comment="Timestamp for when the record was created.",
                        default=django.utils.timezone.now,
                        help_text="The time when the record was created.",
                        verbose_name="Created at",
                    ),
                ),
                (
                    "updated_at",
                    models.DateTimeField(
                        auto_now=True,
                        db_comment="Timestamp for when the record was last updated.",
                        help_text="The time when the record was last updated.",
                        verbose_name="Updated at",
                    ),
                ),
                (
                    "name",
                    models.CharField(
                        db_comment="The name of the audience type.",
                        help_text="The name of the audience type (e.g., Manager, Employee).",
                        max_length=50,
                        unique=True,
                        verbose_name="Audience Name",
                    ),
                ),
                (
                    "description",
                    models.CharField(
                        blank=True,
                        db_comment="Optional description of the audience type.",
                        help_text="A brief description of the audience.",
                        max_length=255,
                        null=True,
                        verbose_name="Description",
                    ),
                ),
            ],
            options={
                "verbose_name": "Audience",
                "verbose_name_plural": "Audiences",
                "db_table": "audiences",
            },
        ),
        migrations.CreateModel(
            name="Announcement",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "created_at",
                    models.DateTimeField(
                        db_comment="Timestamp for when the record was created.",
                        default=django.utils.timezone.now,
                        help_text="The time when the record was created.",
                        verbose_name="Created at",
                    ),
                ),
                (
                    "updated_at",
                    models.DateTimeField(
                        auto_now=True,
                        db_comment="Timestamp for when the record was last updated.",
                        help_text="The time when the record was last updated.",
                        verbose_name="Updated at",
                    ),
                ),
                (
                    "title",
                    models.CharField(
                        db_comment="The main title of the announcement.",
                        help_text="The title of the announcement.",
                        max_length=255,
                        verbose_name="Title",
                    ),
                ),
                (
                    "content",
                    models.TextField(
                        db_comment="Detailed content or description of the announcement.",
                        help_text="The content or description of the announcement.",
                        verbose_name="Content",
                    ),
                ),
                (
                    "published_at",
                    models.DateTimeField(
                        blank=True,
                        db_comment="Timestamp for when the announcement is published.",
                        help_text="The time when the announcement is published.",
                        null=True,
                        verbose_name="Published at",
                    ),
                ),
                (
                    "expires_at",
                    models.DateTimeField(
                        blank=True,
                        db_comment="Timestamp for when the announcement expires.",
                        help_text="The time when the announcement expires.",
                        null=True,
                        verbose_name="Expires at",
                    ),
                ),
                (
                    "attachment",
                    models.FileField(
                        blank=True,
                        db_comment="Optional file attachment related to the announcement.",
                        help_text="An optional file attachment for the announcement (e.g., flyer).",
                        null=True,
                        upload_to="announcement_attachments/",
                        verbose_name="Attachment",
                    ),
                ),
                (
                    "category",
                    models.ForeignKey(
                        db_comment="Foreign key linking to the Category model for announcement classification.",
                        help_text="The category of the announcement.",
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="announcements",
                        to="django_announcement.announcementcategory",
                        verbose_name="Category",
                    ),
                ),
            ],
            options={
                "verbose_name": "Announcement",
                "verbose_name_plural": "Announcements",
                "db_table": "announcements",
            },
        ),
        migrations.CreateModel(
            name="AudienceAnnouncement",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "created_at",
                    models.DateTimeField(
                        db_comment="Timestamp for when the record was created.",
                        default=django.utils.timezone.now,
                        help_text="The time when the record was created.",
                        verbose_name="Created at",
                    ),
                ),
                (
                    "updated_at",
                    models.DateTimeField(
                        auto_now=True,
                        db_comment="Timestamp for when the record was last updated.",
                        help_text="The time when the record was last updated.",
                        verbose_name="Updated at",
                    ),
                ),
                (
                    "announcement",
                    models.ForeignKey(
                        db_comment="Foreign key to the Announcement table, representing the announcement in this relationship.",
                        help_text="The announcement associated with the audience.",
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="announcement_audiences",
                        to="django_announcement.announcement",
                        verbose_name="Announcement",
                    ),
                ),
                (
                    "audience",
                    models.ForeignKey(
                        db_comment="Foreign key to the Audience table, representing the audience in this relationship.",
                        help_text="The audience associated with the announcement.",
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="audience_announcements",
                        to="django_announcement.audience",
                        verbose_name="Audience",
                    ),
                ),
            ],
            options={
                "verbose_name": "Audience Announcement",
                "verbose_name_plural": "Audience Announcements",
                "db_table": "audience_announcement",
                "unique_together": {("announcement", "audience")},
            },
        ),
        migrations.AddField(
            model_name="announcement",
            name="audience",
            field=models.ManyToManyField(
                help_text="The target audience for the announcement.",
                related_name="all_announcements",
                through="django_announcement.AudienceAnnouncement",
                to="django_announcement.audience",
                verbose_name="Audience",
            ),
        ),
        migrations.CreateModel(
            name="UserAnnouncementProfile",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "created_at",
                    models.DateTimeField(
                        db_comment="Timestamp for when the record was created.",
                        default=django.utils.timezone.now,
                        help_text="The time when the record was created.",
                        verbose_name="Created at",
                    ),
                ),
                (
                    "updated_at",
                    models.DateTimeField(
                        auto_now=True,
                        db_comment="Timestamp for when the record was last updated.",
                        help_text="The time when the record was last updated.",
                        verbose_name="Updated at",
                    ),
                ),
                (
                    "user",
                    models.OneToOneField(
                        db_comment="One-to-one relationship with the user.",
                        help_text="The user associated with this profile.",
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="announcement_profile",
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="User",
                    ),
                ),
            ],
            options={
                "verbose_name": "User Announcement Profile",
                "verbose_name_plural": "User Announcement Profiles",
                "db_table": "user_announcement_profiles",
            },
        ),
        migrations.CreateModel(
            name="UserAudience",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "created_at",
                    models.DateTimeField(
                        db_comment="Timestamp for when the record was created.",
                        default=django.utils.timezone.now,
                        help_text="The time when the record was created.",
                        verbose_name="Created at",
                    ),
                ),
                (
                    "updated_at",
                    models.DateTimeField(
                        auto_now=True,
                        db_comment="Timestamp for when the record was last updated.",
                        help_text="The time when the record was last updated.",
                        verbose_name="Updated at",
                    ),
                ),
                (
                    "audience",
                    models.ForeignKey(
                        db_comment="Foreign key to the Audience table.",
                        help_text="The audience associated with the user profile.",
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="audience_users",
                        to="django_announcement.audience",
                        verbose_name="Audience",
                    ),
                ),
                (
                    "user_announce_profile",
                    models.ForeignKey(
                        db_comment="Foreign key to the UserAnnouncementProfile table.",
                        help_text="The user profile associated with the audience.",
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="user_audiences",
                        to="django_announcement.userannouncementprofile",
                        verbose_name="User Profile",
                    ),
                ),
            ],
            options={
                "verbose_name": "User Audience",
                "verbose_name_plural": "User Audiences",
                "db_table": "user_audience",
            },
        ),
        migrations.AddField(
            model_name="userannouncementprofile",
            name="audiences",
            field=models.ManyToManyField(
                help_text="Audiences to which this user belongs.",
                related_name="users",
                through="django_announcement.UserAudience",
                to="django_announcement.audience",
                verbose_name="Audiences",
            ),
        ),
        migrations.AddIndex(
            model_name="announcement",
            index=models.Index(fields=["title", "category"], name="announcement_idx"),
        ),
        migrations.AlterUniqueTogether(
            name="useraudience",
            unique_together={("user_announce_profile", "audience")},
        ),
    ]
