# Generated by Django 4.2.10 on 2024-02-23 17:34

import baseapp_comments.models
import pgtrigger.compiler
import pgtrigger.migrations
from django.db import migrations, models


class Migration(migrations.Migration):
    dependencies = [
        ("baseapp_pages", "0002_page_pageevent_page_snapshot_insert_and_more"),
    ]

    operations = [
        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.AddField(
            model_name="page",
            name="comments_count",
            field=models.JSONField(
                default=baseapp_comments.models.default_comments_count,
                verbose_name="comments count",
            ),
        ),
        migrations.AddField(
            model_name="page",
            name="is_comments_enabled",
            field=models.BooleanField(default=True, verbose_name="is comments enabled"),
        ),
        migrations.AddField(
            model_name="pageevent",
            name="comments_count",
            field=models.JSONField(
                default=baseapp_comments.models.default_comments_count,
                verbose_name="comments count",
            ),
        ),
        migrations.AddField(
            model_name="pageevent",
            name="is_comments_enabled",
            field=models.BooleanField(default=True, verbose_name="is comments enabled"),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="page",
            trigger=pgtrigger.compiler.Trigger(
                name="snapshot_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", "pgh_operation", "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(), \'snapshot\', NEW."id", 1, NEW."status", NEW."title_en", NEW."title_es", NEW."title_pt", NEW."user_id"); RETURN NULL;',
                    hash="9544ebaf84f29fa7995459b3d38d4720f18ddb99",
                    operation="INSERT",
                    pgid="pgtrigger_snapshot_insert_f0c08",
                    table="baseapp_pages_page",
                    when="AFTER",
                ),
            ),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="page",
            trigger=pgtrigger.compiler.Trigger(
                name="snapshot_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", "pgh_operation", "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(), \'snapshot\', NEW."id", 2, NEW."status", NEW."title_en", NEW."title_es", NEW."title_pt", NEW."user_id"); RETURN NULL;',
                    hash="005d125549f0c25f2e06102f5aa651945ff86d8f",
                    operation="UPDATE",
                    pgid="pgtrigger_snapshot_update_845c1",
                    table="baseapp_pages_page",
                    when="AFTER",
                ),
            ),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="page",
            trigger=pgtrigger.compiler.Trigger(
                name="snapshot_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", "pgh_operation", "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(), \'snapshot\', OLD."id", 3, OLD."status", OLD."title_en", OLD."title_es", OLD."title_pt", OLD."user_id"); RETURN NULL;',
                    hash="f00c5e663fabba6d791e84ac44f3b27b2c116e1e",
                    operation="DELETE",
                    pgid="pgtrigger_snapshot_delete_caf3a",
                    table="baseapp_pages_page",
                    when="AFTER",
                ),
            ),
        ),
    ]
