# Generated by Django 4.2.7 on 2023-11-13 15:06

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


class Migration(migrations.Migration):
    dependencies = [
        ("formkit_ninja", "0025_remove_formkitschemanode_protect_deletes_and_more"),
    ]

    operations = [
        pgtrigger.migrations.RemoveTrigger(
            model_name="formkitschemanode",
            name="protect_node_deletes_and_updates",
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="formkitschemanode",
            trigger=pgtrigger.compiler.Trigger(
                name="protect_node_deletes_and_updates",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    condition='WHEN (OLD."protected")',
                    func="RAISE EXCEPTION 'pgtrigger: Cannot delete rows from % table', TG_TABLE_NAME;",
                    hash="6a3c26f53c588934d0ad003a49004c2c796a15cb",
                    operation="DELETE",
                    pgid="pgtrigger_protect_node_deletes_and_updates_a71d1",
                    table="formkit_ninja_formkitschemanode",
                    when="BEFORE",
                ),
            ),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="formkitschemanode",
            trigger=pgtrigger.compiler.Trigger(
                name="protect_node_updates",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    condition='WHEN (OLD."protected" AND NEW."protected")',
                    func="RAISE EXCEPTION 'pgtrigger: Cannot update rows from % table', TG_TABLE_NAME;",
                    hash="6b2b128ac5c8ee328f2367e941d32fd18768c0fb",
                    operation="UPDATE",
                    pgid="pgtrigger_protect_node_updates_2d05b",
                    table="formkit_ninja_formkitschemanode",
                    when="BEFORE",
                ),
            ),
        ),
    ]
