# Generated by Django 5.1.3 on 2026-05-29 09:08

import django.db.models.deletion
import uuid
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("organizations", "0002_workspace_template_user_context_pref"),
        ("platform_workspaces", "0002_remove_navigationitem_feature_and_more"),
        ("tenants", "0001_initial"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="WorkspaceTemplate",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "created_at",
                    models.DateTimeField(
                        auto_now_add=True, db_index=True, verbose_name="created at"
                    ),
                ),
                ("updated_at", models.DateTimeField(auto_now=True, verbose_name="updated at")),
                (
                    "public_id",
                    models.UUIDField(
                        db_index=True,
                        default=uuid.uuid4,
                        editable=False,
                        unique=True,
                        verbose_name="public id",
                    ),
                ),
                ("slug", models.SlugField(max_length=80, unique=True, verbose_name="slug")),
                ("name", models.CharField(max_length=150, verbose_name="name")),
                (
                    "description",
                    models.TextField(blank=True, default="", verbose_name="description"),
                ),
                (
                    "kind",
                    models.CharField(
                        choices=[("internal", "Internal"), ("portal", "Portal")],
                        default="internal",
                        max_length=16,
                        verbose_name="kind",
                    ),
                ),
                (
                    "icon",
                    models.CharField(blank=True, default="", max_length=64, verbose_name="icon"),
                ),
                ("theme", models.JSONField(blank=True, default=dict, verbose_name="theme")),
                (
                    "default_module",
                    models.CharField(
                        blank=True, default="", max_length=80, verbose_name="default module"
                    ),
                ),
                (
                    "navigation_schema",
                    models.JSONField(
                        blank=True,
                        default=list,
                        help_text="List of nav items in NavContribution shape. Instantiated as NavigationItems when a workspace is created from this template.",
                        verbose_name="navigation schema",
                    ),
                ),
                (
                    "is_system",
                    models.BooleanField(
                        default=False,
                        help_text="System templates are read-only and provided by the platform.",
                        verbose_name="system template",
                    ),
                ),
            ],
            options={
                "verbose_name": "workspace template",
                "verbose_name_plural": "workspace templates",
                "ordering": ["name"],
            },
        ),
        migrations.CreateModel(
            name="UserContextPreference",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "created_at",
                    models.DateTimeField(
                        auto_now_add=True, db_index=True, verbose_name="created at"
                    ),
                ),
                ("updated_at", models.DateTimeField(auto_now=True, verbose_name="updated at")),
                (
                    "public_id",
                    models.UUIDField(
                        db_index=True,
                        default=uuid.uuid4,
                        editable=False,
                        unique=True,
                        verbose_name="public id",
                    ),
                ),
                (
                    "active_organization_node",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to="organizations.organizationnode",
                        verbose_name="active organization node",
                    ),
                ),
                (
                    "active_workspace",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to="platform_workspaces.workspace",
                        verbose_name="active workspace",
                    ),
                ),
                (
                    "tenant",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="user_context_preferences",
                        to="tenants.tenant",
                        verbose_name="tenant",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="context_preferences",
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="user",
                    ),
                ),
            ],
            options={
                "verbose_name": "user context preference",
                "verbose_name_plural": "user context preferences",
                "ordering": ["user_id", "tenant_id"],
                "constraints": [
                    models.UniqueConstraint(
                        fields=("user", "tenant"), name="workspaces_userctxpref_unique_user_tenant"
                    )
                ],
            },
        ),
    ]
