# Generated by Django 5.0.6 on 2024-05-20 16:33

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


class Migration(migrations.Migration):

    dependencies = [
        ("baseapp_pages", "0004_alter_page_comments_count_and_more"),
    ]

    operations = [
        pgtrigger.migrations.RemoveTrigger(
            model_name="metadata",
            name="snapshot_insert",
        ),
        pgtrigger.migrations.RemoveTrigger(
            model_name="metadata",
            name="snapshot_update",
        ),
        pgtrigger.migrations.RemoveTrigger(
            model_name="metadata",
            name="snapshot_delete",
        ),
        pgtrigger.migrations.RemoveTrigger(
            model_name="page",
            name="snapshot_insert",
        ),
        pgtrigger.migrations.RemoveTrigger(
            model_name="page",
            name="snapshot_update",
        ),
        pgtrigger.migrations.RemoveTrigger(
            model_name="page",
            name="snapshot_delete",
        ),
        migrations.RemoveField(
            model_name="metadataevent",
            name="pgh_operation",
        ),
        migrations.RemoveField(
            model_name="pageevent",
            name="pgh_operation",
        ),
        migrations.AlterField(
            model_name="metadataevent",
            name="pgh_obj",
            field=models.ForeignKey(
                db_constraint=False,
                on_delete=django.db.models.deletion.DO_NOTHING,
                related_name="events",
                to="baseapp_pages.metadata",
            ),
        ),
        migrations.AlterField(
            model_name="pageevent",
            name="pgh_obj",
            field=models.ForeignKey(
                db_constraint=False,
                on_delete=django.db.models.deletion.DO_NOTHING,
                related_name="events",
                to=settings.BASEAPP_PAGES_PAGE_MODEL,
            ),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="metadata",
            trigger=pgtrigger.compiler.Trigger(
                name="insert_insert",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    func='INSERT INTO "baseapp_pages_metadataevent" ("created", "id", "language", "meta_description", "meta_og_image", "meta_og_type", "meta_robots", "meta_title", "modified", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "target_content_type_id", "target_object_id") VALUES (NEW."created", NEW."id", NEW."language", NEW."meta_description", NEW."meta_og_image", NEW."meta_og_type", NEW."meta_robots", NEW."meta_title", NEW."modified", _pgh_attach_context(), NOW(), \'insert\', NEW."id", NEW."target_content_type_id", NEW."target_object_id"); RETURN NULL;',
                    hash="deb5e56df169fc75ebbb20f54749648c636dadfa",
                    operation="INSERT",
                    pgid="pgtrigger_insert_insert_77686",
                    table="baseapp_pages_metadata",
                    when="AFTER",
                ),
            ),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="metadata",
            trigger=pgtrigger.compiler.Trigger(
                name="update_update",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    condition="WHEN (OLD.* IS DISTINCT FROM NEW.*)",
                    func='INSERT INTO "baseapp_pages_metadataevent" ("created", "id", "language", "meta_description", "meta_og_image", "meta_og_type", "meta_robots", "meta_title", "modified", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "target_content_type_id", "target_object_id") VALUES (NEW."created", NEW."id", NEW."language", NEW."meta_description", NEW."meta_og_image", NEW."meta_og_type", NEW."meta_robots", NEW."meta_title", NEW."modified", _pgh_attach_context(), NOW(), \'update\', NEW."id", NEW."target_content_type_id", NEW."target_object_id"); RETURN NULL;',
                    hash="129d6d409800f020c1454b4a8c0526209632b236",
                    operation="UPDATE",
                    pgid="pgtrigger_update_update_a7a1e",
                    table="baseapp_pages_metadata",
                    when="AFTER",
                ),
            ),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="metadata",
            trigger=pgtrigger.compiler.Trigger(
                name="delete_delete",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    func='INSERT INTO "baseapp_pages_metadataevent" ("created", "id", "language", "meta_description", "meta_og_image", "meta_og_type", "meta_robots", "meta_title", "modified", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "target_content_type_id", "target_object_id") VALUES (OLD."created", OLD."id", OLD."language", OLD."meta_description", OLD."meta_og_image", OLD."meta_og_type", OLD."meta_robots", OLD."meta_title", OLD."modified", _pgh_attach_context(), NOW(), \'delete\', OLD."id", OLD."target_content_type_id", OLD."target_object_id"); RETURN NULL;',
                    hash="cbb78e825a3e4830f3a6847f8348c5995c673078",
                    operation="DELETE",
                    pgid="pgtrigger_delete_delete_be121",
                    table="baseapp_pages_metadata",
                    when="AFTER",
                ),
            ),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="page",
            trigger=pgtrigger.compiler.Trigger(
                name="insert_insert",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    func='INSERT INTO "baseapp_pages_pageevent" ("body_en", "body_es", "body_pt", "comments_count", "created", "id", "is_comments_enabled", "modified", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "status", "title_en", "title_es", "title_pt", "user_id") VALUES (NEW."body_en", NEW."body_es", NEW."body_pt", NEW."comments_count", NEW."created", NEW."id", NEW."is_comments_enabled", NEW."modified", _pgh_attach_context(), NOW(), \'insert\', NEW."id", NEW."status", NEW."title_en", NEW."title_es", NEW."title_pt", NEW."user_id"); RETURN NULL;',
                    hash="fca60194fe041964c87ade0b2147354571d7c81b",
                    operation="INSERT",
                    pgid="pgtrigger_insert_insert_8cd43",
                    table="baseapp_pages_page",
                    when="AFTER",
                ),
            ),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="page",
            trigger=pgtrigger.compiler.Trigger(
                name="update_update",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    condition="WHEN (OLD.* IS DISTINCT FROM NEW.*)",
                    func='INSERT INTO "baseapp_pages_pageevent" ("body_en", "body_es", "body_pt", "comments_count", "created", "id", "is_comments_enabled", "modified", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "status", "title_en", "title_es", "title_pt", "user_id") VALUES (NEW."body_en", NEW."body_es", NEW."body_pt", NEW."comments_count", NEW."created", NEW."id", NEW."is_comments_enabled", NEW."modified", _pgh_attach_context(), NOW(), \'update\', NEW."id", NEW."status", NEW."title_en", NEW."title_es", NEW."title_pt", NEW."user_id"); RETURN NULL;',
                    hash="4508dc486b60f0c91ff5f7402d57989b2c0a5354",
                    operation="UPDATE",
                    pgid="pgtrigger_update_update_2aae7",
                    table="baseapp_pages_page",
                    when="AFTER",
                ),
            ),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="page",
            trigger=pgtrigger.compiler.Trigger(
                name="delete_delete",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    func='INSERT INTO "baseapp_pages_pageevent" ("body_en", "body_es", "body_pt", "comments_count", "created", "id", "is_comments_enabled", "modified", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "status", "title_en", "title_es", "title_pt", "user_id") VALUES (OLD."body_en", OLD."body_es", OLD."body_pt", OLD."comments_count", OLD."created", OLD."id", OLD."is_comments_enabled", OLD."modified", _pgh_attach_context(), NOW(), \'delete\', OLD."id", OLD."status", OLD."title_en", OLD."title_es", OLD."title_pt", OLD."user_id"); RETURN NULL;',
                    hash="7221ed652b5d849d6be91b97fb857357b0bbafa4",
                    operation="DELETE",
                    pgid="pgtrigger_delete_delete_7e0fa",
                    table="baseapp_pages_page",
                    when="AFTER",
                ),
            ),
        ),
    ]
