# Generated by Django 3.2.14 on 2022-08-05 06:45

from django.conf import settings
import django.contrib.postgres.fields
import django.contrib.postgres.indexes
from django.contrib.postgres.operations import CreateExtension
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 = [
        CreateExtension('intarray'),

        migrations.CreateModel(
            name='ObjectAccess',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('object_id', models.PositiveIntegerField(verbose_name='Object: Identifier')),
                ('gathered_permission_ids', django.contrib.postgres.fields.ArrayField(base_field=models.IntegerField(), blank=True, default=list, size=None, verbose_name='Gathered permissions')),
                ('group_ids', django.contrib.postgres.fields.ArrayField(base_field=models.IntegerField(), blank=True, default=list, size=None, verbose_name='Groups')),
                ('permission_ids', django.contrib.postgres.fields.ArrayField(base_field=models.IntegerField(), blank=True, default=list, size=None, verbose_name='Permissions')),
                ('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.contenttype', verbose_name='Object: Content type')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='User')),
            ],
            options={
                'verbose_name': 'Object access',
                'verbose_name_plural': 'Object accesses',
            },
        ),
        migrations.AddIndex(
            model_name='objectaccess',
            index=models.Index(fields=['content_type', 'object_id'], name='pxd_legate__content_1fe8f8_idx'),
        ),
        migrations.AddIndex(
            model_name='objectaccess',
            index=django.contrib.postgres.indexes.GinIndex(fields=['gathered_permission_ids'], name='pxd_legate_objectaccess_gth', opclasses=('gin__int_ops',)),
        ),
        migrations.AddIndex(
            model_name='objectaccess',
            index=django.contrib.postgres.indexes.GinIndex(fields=['group_ids'], name='pxd_legate_objectaccess_groups', opclasses=('gin__int_ops',)),
        ),
        migrations.AddIndex(
            model_name='objectaccess',
            index=django.contrib.postgres.indexes.GinIndex(fields=['permission_ids'], name='pxd_legate_objectaccess_perms', opclasses=('gin__int_ops',)),
        ),
        migrations.AlterUniqueTogether(
            name='objectaccess',
            unique_together={('user', 'content_type', 'object_id')},
        ),
    ]
