# Generated by Django 4.2.6 on 2023-10-22 18:21

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("core", "0058_migrate_preferences_to_global"),
    ]

    operations = ([
        migrations.AlterModelManagers(
            name="activity",
            managers=[],
        ),
        migrations.AlterModelManagers(
            name="additionalfield",
            managers=[],
        ),
        migrations.AlterModelManagers(
            name="announcementrecipient",
            managers=[],
        ),
        migrations.AlterModelManagers(
            name="custommenu",
            managers=[],
        ),
        migrations.AlterModelManagers(
            name="custommenuitem",
            managers=[],
        ),
        migrations.AlterModelManagers(
            name="datacheckresult",
            managers=[],
        ),
        migrations.AlterModelManagers(
            name="grouptype",
            managers=[],
        ),
        migrations.AlterModelManagers(
            name="notification",
            managers=[],
        ),
        migrations.AlterModelManagers(
            name="organisation",
            managers=[],
        ),
        migrations.AlterModelManagers(
            name="pdffile",
            managers=[],
        ),
        migrations.AlterModelManagers(
            name="person",
            managers=[],
        ),
        migrations.AlterModelManagers(
            name="persongroupthrough",
            managers=[],
        ),
        migrations.AlterModelManagers(
            name="room",
            managers=[],
        ),
        migrations.AlterModelManagers(
            name="taskuserassignment",
            managers=[],
        ),
        migrations.RemoveConstraint(
            model_name="additionalfield",
            name="unique_title_per_site",
        ),
        migrations.RemoveConstraint(
            model_name="custommenu",
            name="unique_menu_name_per_site",
        ),
        migrations.RemoveConstraint(
            model_name="group",
            name="unique_school_term_name",
        ),
        migrations.RemoveConstraint(
            model_name="group",
            name="unique_school_term_short_name",
        ),
        migrations.RemoveConstraint(
            model_name="grouptype",
            name="unique_group_type_name_per_site",
        ),
        migrations.RemoveConstraint(
            model_name="person",
            name="unique_short_name_per_site",
        ),
        migrations.RemoveConstraint(
            model_name="room",
            name="unique_room_short_name_per_site",
        ),
        migrations.RemoveConstraint(
            model_name="schoolterm",
            name="unique_school_term_name_per_site",
        ),
        migrations.RemoveConstraint(
            model_name="schoolterm",
            name="unique_school_term_dates_per_site",
        ),
    ] + [
        migrations.RunSQL(
            f"ALTER TABLE core_{model_name} drop column if exists site_id;"
        ) for model_name  in
        [
            "activity",
            "additionalfield",
            "announcement",
            "announcementrecipient",
            "calendarevent",
            "custommenu",
            "custommenuitem",
            "dashboardwidgetorder",
            "datacheckresult",
            "group",
            "grouptype",
            "notification",
            "organisation",
            "pdffile",
            "person",
            "persongroupthrough",
            "room",
            "schoolterm",
            "taskuserassignment"
        ]
    ] +  [
        migrations.DeleteModel(
            name="SitePreferenceModel",
        ),
        migrations.AddConstraint(
            model_name="additionalfield",
            constraint=models.UniqueConstraint(fields=("title",), name="unique_title"),
        ),
        migrations.AddConstraint(
            model_name="custommenu",
            constraint=models.UniqueConstraint(fields=("name",), name="unique_menu_name"),
        ),
        migrations.AddConstraint(
            model_name="group",
            constraint=models.UniqueConstraint(
                fields=("school_term", "name"), name="unique_school_term_name_group"
            ),
        ),
        migrations.AddConstraint(
            model_name="group",
            constraint=models.UniqueConstraint(
                fields=("school_term", "short_name"), name="unique_school_term_short_name_group"
            ),
        ),
        migrations.AddConstraint(
            model_name="grouptype",
            constraint=models.UniqueConstraint(fields=("name",), name="unique_group_type_name"),
        ),
        migrations.AddConstraint(
            model_name="person",
            constraint=models.UniqueConstraint(fields=("short_name",), name="unique_short_name"),
        ),
        migrations.AddConstraint(
            model_name="room",
            constraint=models.UniqueConstraint(
                fields=("short_name",), name="unique_room_short_name"
            ),
        ),
        migrations.AddConstraint(
            model_name="schoolterm",
            constraint=models.UniqueConstraint(fields=("name",), name="unique_school_term_name"),
        ),
        migrations.AddConstraint(
            model_name="schoolterm",
            constraint=models.UniqueConstraint(
                fields=("date_start", "date_end"), name="unique_school_term_dates"
            ),
        ),
    ])
