# Generated by Django 3.2.18 on 2023-05-31 20:19

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("models", "9437_include_map_source_and_map_layer_permissions"),
    ]

    operations = [
        migrations.AddField(
            model_name="etlmodule",
            name="helpsortorder",
            field=models.IntegerField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name="etlmodule",
            name="helptemplate",
            field=models.TextField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name="plugin",
            name="helptemplate",
            field=models.TextField(blank=True, null=True),
        ),
        migrations.RunSQL(
            """
                UPDATE etl_modules
                SET helptemplate = vals.helptemplate,
                    helpsortorder = vals.helpsortorder
                FROM (values
                    ('bulk-manager-case-help', 1)
                ) as vals(helptemplate, helpsortorder)
                WHERE componentname = 'bulk-case-editor';

                UPDATE etl_modules
                SET helptemplate = vals.helptemplate,
                    helpsortorder = vals.helpsortorder
                FROM (values
                    ('bulk-manager-replace-help', 2)
                ) as vals(helptemplate, helpsortorder)
                WHERE componentname = 'bulk-replace-editor';

                UPDATE etl_modules
                SET helptemplate = vals.helptemplate,
                    helpsortorder = vals.helpsortorder
                FROM (values
                    ('bulk-manager-trim-help', 3)
                ) as vals(helptemplate, helpsortorder)
                WHERE componentname = 'bulk-trim-editor';

                UPDATE etl_modules
                SET helptemplate = vals.helptemplate,
                    helpsortorder = vals.helpsortorder
                FROM (values
                    ('import-branch-csv-help', 4)
                ) as vals(helptemplate, helpsortorder)
                WHERE componentname = 'branch-csv-importer';

                UPDATE etl_modules
                SET helptemplate = vals.helptemplate,
                    helpsortorder = vals.helpsortorder
                FROM (values
                    ('import-single-csv-help', 5)
                ) as vals(helptemplate, helpsortorder)
                WHERE componentname = 'import-single-csv';
            """,
            reverse_sql="""
                UPDATE etl_modules
                SET helptemplate = NULL,
                    helpsortorder = NULL
            """,
        ),
    ]
