# Generated by Django 5.1.3 on 2024-11-15 07:42

import django.contrib.postgres.constraints
import django.db.models.deletion
import users.sentinel
from django.conf import settings
from django.db import migrations, models
from django.contrib.postgres.operations import BtreeGistExtension


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('albums', '0001_initial'),
        ('auth', '0012_alter_user_first_name_max_length'),
        ('files', '0002_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        BtreeGistExtension(),
        migrations.AddField(
            model_name='album',
            name='owner',
            field=models.ForeignKey(help_text='The creator of this album.', on_delete=models.SET(users.sentinel.get_sentinel_user), related_name='albums', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='albumgroupobjectpermission',
            name='content_object',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='group_permissions', to='albums.album'),
        ),
        migrations.AddField(
            model_name='albumgroupobjectpermission',
            name='group',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='auth.group'),
        ),
        migrations.AddField(
            model_name='albumgroupobjectpermission',
            name='permission',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='auth.permission'),
        ),
        migrations.AddField(
            model_name='albummember',
            name='album',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='memberships', to='albums.album'),
        ),
        migrations.AddField(
            model_name='albummember',
            name='basefile',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='memberships', to='files.basefile'),
        ),
        migrations.AddField(
            model_name='album',
            name='files',
            field=models.ManyToManyField(related_name='albums', through='albums.AlbumMember', to='files.basefile'),
        ),
        migrations.AddField(
            model_name='albumuserobjectpermission',
            name='content_object',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='user_permissions', to='albums.album'),
        ),
        migrations.AddField(
            model_name='albumuserobjectpermission',
            name='permission',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='auth.permission'),
        ),
        migrations.AddField(
            model_name='albumuserobjectpermission',
            name='user',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
        ),
        migrations.AlterUniqueTogether(
            name='albumgroupobjectpermission',
            unique_together={('group', 'permission', 'content_object')},
        ),
        migrations.AddConstraint(
            model_name='albummember',
            constraint=django.contrib.postgres.constraints.ExclusionConstraint(expressions=[(models.F('basefile'), '='), (models.F('album'), '='), ('period', '&&')], name='prevent_membership_overlaps'),
        ),
        migrations.AlterUniqueTogether(
            name='albumuserobjectpermission',
            unique_together={('user', 'permission', 'content_object')},
        ),
    ]
