# Generated by Django 4.2.5 on 2023-10-01 11:43

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

from formkit_ninja import triggers


class Migration(migrations.Migration):
    dependencies = [
        ("formkit_ninja", "0018_remove_formcomponents_order_on_insert_option_and_more"),
    ]

    operations = [
        # Note that this was added to create the sequence
        migrations.RunSQL(*triggers.create_sequence_migration(triggers.NODE_CHANGE_ID)),
        migrations.AddField(
            model_name="formkitschemanode",
            name="track_change",
            field=models.BigIntegerField(blank=True, null=True),
        ),
        pgtrigger.migrations.AddTrigger(
            model_name="formkitschemanode",
            trigger=pgtrigger.compiler.Trigger(
                name="version_on_update",
                sql=pgtrigger.compiler.UpsertTriggerSql(
                    func="NEW.\"track_change\" = nextval('formkitschemanode_change_id'); RETURN NEW;",
                    hash="23d8a7e6e73b7b06f75c07e679c192634ec2a6d9",
                    operation="UPDATE OR INSERT",
                    pgid="pgtrigger_version_on_update_09b77",
                    table="formkit_ninja_formkitschemanode",
                    when="BEFORE",
                ),
            ),
        ),
    ]
