# Generated by Django 3.1.2 on 2020-10-22 10:10

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('contenttypes', '0002_remove_content_type_name'),
    ]

    operations = [
        migrations.CreateModel(
            name='Role',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('role_field', models.CharField(choices=[('global_superuser', 'System Superuser: Global and root access to the application'), ('global_admin', 'System Administrator: Global administrator of the application'), ('global_staff', 'System Staff: Global staff member of the application')], max_length=64, verbose_name='Role Key')),
                ('singleton_name', models.CharField(blank=True, choices=[('global_superuser', 'System Superuser: Global and root access to the application'), ('global_admin', 'System Administrator: Global administrator of the application'), ('global_staff', 'System Staff: Global staff member of the application')], db_index=True, default=None, max_length=64, null=True, unique=True, verbose_name='Singleton Name')),
                ('object_id', models.PositiveIntegerField(blank=True, default=None, null=True)),
                ('implicit_parents', models.TextField(default='[]')),
            ],
            options={
                'verbose_name': 'Role',
                'verbose_name_plural': 'Roles',
                'ordering': ('content_type', 'object_id'),
                'default_related_name': 'roles',
            },
        ),
        migrations.CreateModel(
            name='RoleAncestorEntry',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('role_field', models.CharField(max_length=64)),
                ('content_type_id', models.PositiveIntegerField()),
                ('object_id', models.PositiveIntegerField()),
                ('ancestor', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', to='drf_magic.role')),
                ('descendent', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', to='drf_magic.role')),
            ],
            options={
                'verbose_name': 'Role Ancestor',
                'verbose_name_plural': 'Role Ancestors',
                'db_table': 'core_role_ancestors',
                'index_together': {('ancestor', 'content_type_id', 'role_field'), ('ancestor', 'content_type_id', 'object_id'), ('ancestor', 'descendent')},
            },
        ),
        migrations.AddField(
            model_name='role',
            name='ancestors',
            field=models.ManyToManyField(related_name='descendents', through='drf_magic.RoleAncestorEntry', to='drf_magic.Role'),
        ),
        migrations.AddField(
            model_name='role',
            name='content_type',
            field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='roles', to='contenttypes.contenttype'),
        ),
        migrations.AddField(
            model_name='role',
            name='members',
            field=models.ManyToManyField(blank=True, related_name='roles', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='role',
            name='parents',
            field=models.ManyToManyField(blank=True, related_name='children', to='drf_magic.Role'),
        ),
        migrations.AlterIndexTogether(
            name='role',
            index_together={('content_type', 'object_id')},
        ),
    ]
