# Generated by Django 5.1.3 on 2026-05-24 17:03

from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("organizations", "0001_initial"),
        ("platform_modules", "0003_feature_alter_featureentitlement_options_and_more"),
        ("tenants", "0001_initial"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.AlterModelOptions(
            name="featureentitlement",
            options={
                "ordering": ("module__name", "feature_code"),
                "verbose_name": "feature entitlement",
                "verbose_name_plural": "feature entitlements",
            },
        ),
        migrations.RemoveConstraint(
            model_name="featureentitlement",
            name="modules_feature_entitlement_unique_scope",
        ),
        migrations.RemoveIndex(
            model_name="featureentitlement",
            name="platform_mo_tenant__432af5_idx",
        ),
        migrations.RemoveField(
            model_name="featureentitlement",
            name="features",
        ),
        migrations.AddField(
            model_name="featureentitlement",
            name="feature_code",
            field=models.CharField(
                db_index=True,
                default="",
                help_text="Dotted code identifying the feature, e.g. 'chat.group_messaging'.",
                max_length=80,
                verbose_name="feature code",
            ),
            preserve_default=False,
        ),
        migrations.AddIndex(
            model_name="featureentitlement",
            index=models.Index(
                fields=["tenant", "module", "feature_code"], name="platform_mo_tenant__cbddff_idx"
            ),
        ),
        migrations.AddConstraint(
            model_name="featureentitlement",
            constraint=models.UniqueConstraint(
                fields=("tenant", "module", "feature_code", "user"),
                name="modules_feature_entitlement_unique_scope",
            ),
        ),
    ]
