# Generated by Django 5.2.6 on 2026-06-10 17:01

import django.db.models.deletion
import uuid
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("platform_modules", "0009_update_navigationitem_feature_fk"),
    ]

    operations = [
        migrations.AddField(
            model_name="featurecatalog",
            name="addon_price",
            field=models.DecimalField(
                blank=True,
                decimal_places=2,
                help_text="Price when purchased as a standalone add-on.",
                max_digits=12,
                null=True,
                verbose_name="add-on price",
            ),
        ),
        migrations.AddField(
            model_name="featurecatalog",
            name="category",
            field=models.CharField(
                choices=[
                    ("platform", "Platform"),
                    ("business", "Business"),
                    ("vertical", "Vertical"),
                    ("ai", "AI"),
                ],
                db_index=True,
                default="business",
                max_length=16,
                verbose_name="category",
            ),
        ),
        migrations.AddField(
            model_name="featurecatalog",
            name="is_always_on",
            field=models.BooleanField(
                default=False,
                help_text="If True this feature is always enabled — platform internals.",
                verbose_name="always on",
            ),
        ),
        migrations.AddField(
            model_name="featurecatalog",
            name="is_platform_internal",
            field=models.BooleanField(
                default=False,
                help_text="If True this feature is never sold or licensed to tenants.",
                verbose_name="platform internal",
            ),
        ),
        migrations.AddField(
            model_name="tenantfeatureoverride",
            name="feature_key",
            field=models.CharField(
                blank=True,
                db_index=True,
                default="",
                help_text="Dotted key, e.g. 'crm.pipeline'. Will replace module FK in Phase 2.",
                max_length=120,
                verbose_name="feature key",
            ),
        ),
        migrations.AlterField(
            model_name="tenantfeatureoverride",
            name="module",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name="feature_overrides",
                to="platform_modules.tenantmodule",
            ),
        ),
        migrations.CreateModel(
            name="ModuleFeature",
            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",
                    ),
                ),
                (
                    "module_code",
                    models.CharField(
                        db_index=True,
                        help_text="The module that provides this feature, e.g. 'crm'.",
                        max_length=80,
                        verbose_name="module code",
                    ),
                ),
                (
                    "feature_key",
                    models.CharField(
                        db_index=True,
                        help_text="Dotted key, e.g. 'crm.pipeline'.",
                        max_length=120,
                        verbose_name="feature key",
                    ),
                ),
                (
                    "required",
                    models.BooleanField(
                        default=False,
                        help_text="True if this feature is mandatory for the module to function.",
                        verbose_name="required",
                    ),
                ),
                (
                    "default_enabled",
                    models.BooleanField(
                        default=True,
                        help_text="Whether the feature is on by default when the module is provisioned.",
                        verbose_name="default enabled",
                    ),
                ),
            ],
            options={
                "verbose_name": "module feature",
                "verbose_name_plural": "module features",
                "ordering": ("module_code", "feature_key"),
                "indexes": [
                    models.Index(
                        fields=["module_code", "feature_key"], name="platform_mo_module__d80464_idx"
                    )
                ],
                "constraints": [
                    models.UniqueConstraint(
                        fields=("module_code", "feature_key"),
                        name="platform_modules_modulefeature_unique",
                    )
                ],
            },
        ),
    ]
