# Generated by Django 6.0.1 on 2026-05-19 08:26

import django.db.models.deletion
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="Room",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(max_length=100)),
                ("slug", models.SlugField(unique=True)),
                ("description", models.TextField(blank=True)),
                (
                    "room_type",
                    models.CharField(
                        choices=[
                            ("neighborhood", "Neighborhood"),
                            ("topic", "Topic"),
                            ("university", "University"),
                            ("election", "Election / Ward"),
                            ("business", "Biashara"),
                        ],
                        default="topic",
                        max_length=20,
                    ),
                ),
                ("icon", models.CharField(blank=True, default="💬", max_length=10)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("is_active", models.BooleanField(default=True)),
                ("member_count", models.PositiveIntegerField(default=0)),
                (
                    "created_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="created_rooms",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["room_type", "name"],
            },
        ),
        migrations.CreateModel(
            name="RoomMembership",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "role",
                    models.CharField(
                        choices=[
                            ("member", "Member"),
                            ("moderator", "Moderator"),
                            ("admin", "Admin"),
                        ],
                        default="member",
                        max_length=20,
                    ),
                ),
                ("joined_at", models.DateTimeField(auto_now_add=True)),
                ("is_muted", models.BooleanField(default=False)),
                (
                    "room",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, to="community.room"
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "unique_together": {("user", "room")},
            },
        ),
        migrations.AddField(
            model_name="room",
            name="members",
            field=models.ManyToManyField(
                blank=True,
                related_name="rooms",
                through="community.RoomMembership",
                to=settings.AUTH_USER_MODEL,
            ),
        ),
    ]
