# Generated by Django 6.0.1 on 2026-01-22 02:28

from django.conf import settings
from django.db import migrations, models
from django.utils import timezone


class Migration(migrations.Migration):
    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        migrations.swappable_dependency(settings.SAAS_TENANT_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Group',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(db_index=True, max_length=100)),
                ('permissions', models.JSONField(default=list)),
                ('managed', models.BooleanField(default=False)),
                ('created_at', models.DateTimeField(db_index=True, default=timezone.now)),
                ('tenant', models.ForeignKey(on_delete=models.CASCADE, to=settings.SAAS_TENANT_MODEL)),
            ],
            options={
                'verbose_name': 'group',
                'verbose_name_plural': 'groups',
                'db_table': 'saas_tenancy_group',
                'ordering': ['created_at'],
                'unique_together': {('tenant', 'name')},
            },
        ),
        migrations.CreateModel(
            name='Member',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(db_index=True, default=timezone.now)),
                ('role', models.CharField(blank=True, max_length=50, null=True)),
                ('permissions', models.JSONField(default=list)),
                ('groups', models.ManyToManyField(blank=True, to='saas_tenancy.group')),
                ('tenant', models.ForeignKey(on_delete=models.CASCADE, to=settings.SAAS_TENANT_MODEL)),
                ('user', models.ForeignKey(null=True, on_delete=models.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'member',
                'verbose_name_plural': 'members',
                'db_table': 'saas_tenancy_member',
                'ordering': ['-created_at'],
                'unique_together': {('tenant', 'user')},
            },
        ),
    ]
