# Generated by Django 4.2.7 on 2023-11-11 04:25

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


class Migration(migrations.Migration):
    dependencies = [
        ("formkit_ninja", "0023_formkitschemanodeevent_and_more"),
    ]

    operations = [
        pgtrigger.migrations.RemoveTrigger(
            model_name="formkitschemanode",
            name="insert_insert",
        ),
        pgtrigger.migrations.RemoveTrigger(
            model_name="formkitschemanode",
            name="update_update",
        ),
        migrations.AddField(
            model_name="formkitschemanode",
            name="protected",
            field=models.BooleanField(default=False),
        ),
        migrations.AddField(
            model_name="formkitschemanodeevent",
            name="protected",
            field=models.BooleanField(default=False),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="formkitschemanode",
            trigger=pgtrigger.compiler.Trigger(
                name="protect_deletes",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    condition='WHEN (OLD."protected")',
                    func="RAISE EXCEPTION 'pgtrigger: Cannot delete rows from % table', TG_TABLE_NAME;",
                    hash="4d74bdff98561d69e24a51782fd756b9410242b4",
                    operation="DELETE",
                    pgid="pgtrigger_protect_deletes_ec7d5",
                    table="formkit_ninja_formkitschemanode",
                    when="BEFORE",
                ),
            ),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="formkitschemanode",
            trigger=pgtrigger.compiler.Trigger(
                name="insert_insert",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    func='INSERT INTO "formkit_ninja_formkitschemanodeevent" ("additional_props", "created", "created_by_id", "description", "id", "is_active", "label", "node", "node_type", "option_group_id", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "protected", "text_content", "track_change", "updated", "updated_by_id") VALUES (NEW."additional_props", NEW."created", NEW."created_by_id", NEW."description", NEW."id", NEW."is_active", NEW."label", NEW."node", NEW."node_type", NEW."option_group_id", _pgh_attach_context(), NOW(), \'insert\', NEW."id", NEW."protected", NEW."text_content", NEW."track_change", NEW."updated", NEW."updated_by_id"); RETURN NULL;',
                    hash="c5bce62ecf2f791f422ee61d09f7cedeccee6637",
                    operation="INSERT",
                    pgid="pgtrigger_insert_insert_72c4c",
                    table="formkit_ninja_formkitschemanode",
                    when="AFTER",
                ),
            ),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="formkitschemanode",
            trigger=pgtrigger.compiler.Trigger(
                name="update_update",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    condition="WHEN (OLD.* IS DISTINCT FROM NEW.*)",
                    func='INSERT INTO "formkit_ninja_formkitschemanodeevent" ("additional_props", "created", "created_by_id", "description", "id", "is_active", "label", "node", "node_type", "option_group_id", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "protected", "text_content", "track_change", "updated", "updated_by_id") VALUES (NEW."additional_props", NEW."created", NEW."created_by_id", NEW."description", NEW."id", NEW."is_active", NEW."label", NEW."node", NEW."node_type", NEW."option_group_id", _pgh_attach_context(), NOW(), \'update\', NEW."id", NEW."protected", NEW."text_content", NEW."track_change", NEW."updated", NEW."updated_by_id"); RETURN NULL;',
                    hash="03fbb3ba0fbdd08226bdc6ab9bfc423dc993cf2b",
                    operation="UPDATE",
                    pgid="pgtrigger_update_update_d7c99",
                    table="formkit_ninja_formkitschemanode",
                    when="AFTER",
                ),
            ),
        ),
    ]
