# Generated by Django 5.0.7 on 2024-08-12 23:19

import django_db_views.migration_functions
import django_db_views.operations
from django.db import migrations


class Migration(migrations.Migration):

    dependencies = [
        ("edc_qareports", "0010_auto_20240812_1918"),
    ]

    operations = [
        django_db_views.operations.ViewRunPython(
            code=django_db_views.migration_functions.ForwardViewMigration(
                "select *, uuid() as `id`, now() as `created` from (\n        select site_id, username, report_model, min(accessed) as `first_accessed`,\n               max(accessed) as `last_accessed`, count(*) as `access_count`\n        from edc_qareports_qareportlog\n        group by username, report_model, site_id\n    ) as A\n    order by username, report_model",
                "qa_report_log_summary_view",
                engine="django.db.backends.mysql",
            ),
            reverse_code=django_db_views.migration_functions.BackwardViewMigration(
                "", "qa_report_log_summary_view", engine="django.db.backends.mysql"
            ),
            atomic=False,
        ),
        django_db_views.operations.ViewRunPython(
            code=django_db_views.migration_functions.ForwardViewMigration(
                "select *, get_random_uuid() as id, now() as created (\n        select site_id, username, report_model, min(accessed) as first_accessed,\n               max(accessed) as last_accessed, count(*) as access_count\n        from edc_qareports_qareportlog\n        group by username, report_model, site_id\n    ) as A\n    order by username, report_model",
                "qa_report_log_summary_view",
                engine="django.db.backends.postgresql",
            ),
            reverse_code=django_db_views.migration_functions.BackwardViewMigration(
                "", "qa_report_log_summary_view", engine="django.db.backends.postgresql"
            ),
            atomic=False,
        ),
        django_db_views.operations.ViewRunPython(
            code=django_db_views.migration_functions.ForwardViewMigration(
                "SELECT *, lower(\n    hex(randomblob(4)) || '-' || hex(randomblob(2)) || '-' || '4' ||\n    substr(hex( randomblob(2)), 2) || '-' ||\n    substr('AB89', 1 + (abs(random()) % 4) , 1)  ||\n    substr(hex(randomblob(2)), 2) || '-' ||\n    hex(randomblob(6))\n  ) as id, datetime() as created from (\n        select site_id, username, report_model, min(accessed) as first_accessed,\n               max(accessed) as last_accessed, count(*) as access_count\n        from edc_qareports_qareportlog\n        group by username, report_model, site_id\n    ) as A\n    order by username, report_model",
                "qa_report_log_summary_view",
                engine="django.db.backends.sqlite3",
            ),
            reverse_code=django_db_views.migration_functions.BackwardViewMigration(
                "", "qa_report_log_summary_view", engine="django.db.backends.sqlite3"
            ),
            atomic=False,
        ),
    ]
