# Generated by Django 5.2.8 on 2025-12-16 17:56

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('core', '0028_tenantstorageusage'),
        ('users', '0010_add_stripe_customer_fields'),
    ]

    operations = [
        migrations.CreateModel(
            name='StaffRole',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(help_text='Display name of the role', max_length=100)),
                ('description', models.TextField(blank=True, default='', help_text='Description of what this role can do')),
                ('permissions', models.JSONField(blank=True, default=dict, help_text='Permission keys and their boolean values')),
                ('is_default', models.BooleanField(default=False, help_text='True for system-created default roles')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('tenant', models.ForeignKey(help_text='Tenant this role belongs to', on_delete=django.db.models.deletion.CASCADE, related_name='staff_roles', to='core.tenant')),
            ],
            options={
                'ordering': ['-is_default', 'name'],
            },
        ),
        migrations.AddField(
            model_name='staffinvitation',
            name='staff_role',
            field=models.ForeignKey(blank=True, help_text='Staff role to assign when invitation is accepted (for TENANT_STAFF only)', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='invitations', to='users.staffrole'),
        ),
        migrations.AddField(
            model_name='user',
            name='staff_role',
            field=models.ForeignKey(blank=True, help_text='Assigned staff role (for TENANT_STAFF only)', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='staff_members', to='users.staffrole'),
        ),
        migrations.AddIndex(
            model_name='staffrole',
            index=models.Index(fields=['tenant', 'is_default'], name='users_staff_tenant__53464c_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='staffrole',
            unique_together={('tenant', 'name')},
        ),
    ]
