Wagtail 5.1.3 update Can't cast Integer to Jsonb
Tags: wagtail
Published: 2023-11-13 09:44:58

After I updated to wagtail 5.1.3 and had to set use_json_field=True to every StreamField, I got an error in an old migration file :



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uoj74s1xec9xsw1ghkeh.png)


I did a custom migration and it worked but I had to remove this migration , I need a solution without removing this migration. 

```
# Generated by Django 4.1.9 on 2023-06-07 12:08

from django.db import migrations
import wagtail.admin.forms.choosers
import wagtail.blocks
import wagtail.documents.blocks
import wagtail.fields


class Migration(migrations.Migration):

    dependencies = [
        ('cms', '0036_remove_externallinks_site'),
    ]

    operations = [
        migrations.RemoveField(
            model_name='footerlinks',
            name='privacy_policy_label',
        ),
        migrations.RemoveField(
            model_name='footerlinks',
            name='terms_conditions_client_label',
        ),
        migrations.RemoveField(
            model_name='footerlinks',
            name='terms_conditions_visual_creator_label',
        ),
        migrations.AlterField(
            model_name='footerlinks',
            name='privacy_policy',
            field=wagtail.fields.StreamField([('footer_link', wagtail.blocks.StructBlock([('label', wagtail.blocks.CharBlock(max_length=100)), ('link', wagtail.blocks.StructBlock([('link_to', wagtail.blocks.ChoiceBlock(choices=[('page', 'Page'), ('file', 'File'), ('custom_url', 'Custom URL'), ('email', 'Email'), ('anchor', 'Anchor'), ('phone', 'Phone')], classname='link_choice_type_selector', label='Link to', required=False)), ('page', wagtail.blocks.PageChooserBlock(form_classname='page_link', label='Page', required=False)), ('file', wagtail.documents.blocks.DocumentChooserBlock(form_classname='file_link', label='File', required=False)), ('custom_url', wagtail.blocks.CharBlock(form_classname='custom_url_link url_field', label='Custom URL', max_length=300, required=False, validators=[wagtail.admin.forms.choosers.URLOrAbsolutePathValidator()])), ('anchor', wagtail.blocks.CharBlock(form_classname='anchor_link', label='#', max_length=300, required=False)), ('email', wagtail.blocks.EmailBlock(required=False)), ('phone', wagtail.blocks.CharBlock(form_classname='phone_link', label='Phone', max_length=30, required=False)), ('new_window', wagtail.blocks.BooleanBlock(form_classname='new_window_toggle', label='Open in new window', required=False))]))], label='Privacy Policy'))], null=True, use_json_field=True),
        ),
        migrations.AlterField(
            model_name='footerlinks',
            name='terms_conditions_client',
            field=wagtail.fields.StreamField([('footer_link', wagtail.blocks.StructBlock([('label', wagtail.blocks.CharBlock(max_length=100)), ('link', wagtail.blocks.StructBlock([('link_to', wagtail.blocks.ChoiceBlock(choices=[('page', 'Page'), ('file', 'File'), ('custom_url', 'Custom URL'), ('email', 'Email'), ('anchor', 'Anchor'), ('phone', 'Phone')], classname='link_choice_type_selector', label='Link to', required=False)), ('page', wagtail.blocks.PageChooserBlock(form_classname='page_link', label='Page', required=False)), ('file', wagtail.documents.blocks.DocumentChooserBlock(form_classname='file_link', label='File', required=False)), ('custom_url', wagtail.blocks.CharBlock(form_classname='custom_url_link url_field', label='Custom URL', max_length=300, required=False, validators=[wagtail.admin.forms.choosers.URLOrAbsolutePathValidator()])), ('anchor', wagtail.blocks.CharBlock(form_classname='anchor_link', label='#', max_length=300, required=False)), ('email', wagtail.blocks.EmailBlock(required=False)), ('phone', wagtail.blocks.CharBlock(form_classname='phone_link', label='Phone', max_length=30, required=False)), ('new_window', wagtail.blocks.BooleanBlock(form_classname='new_window_toggle', label='Open in new window', required=False))]))], label='Terms & Conditions for Client'))], null=True, use_json_field=True),
        ),
        migrations.AlterField(
            model_name='footerlinks',
            name='terms_conditions_visual_creator',
            field=wagtail.fields.StreamField([('footer_link', wagtail.blocks.StructBlock([('label', wagtail.blocks.CharBlock(max_length=100)), ('link', wagtail.blocks.StructBlock([('link_to', wagtail.blocks.ChoiceBlock(choices=[('page', 'Page'), ('file', 'File'), ('custom_url', 'Custom URL'), ('email', 'Email'), ('anchor', 'Anchor'), ('phone', 'Phone')], classname='link_choice_type_selector', label='Link to', required=False)), ('page', wagtail.blocks.PageChooserBlock(form_classname='page_link', label='Page', required=False)), ('file', wagtail.documents.blocks.DocumentChooserBlock(form_classname='file_link', label='File', required=False)), ('custom_url', wagtail.blocks.CharBlock(form_classname='custom_url_link url_field', label='Custom URL', max_length=300, required=False, validators=[wagtail.admin.forms.choosers.URLOrAbsolutePathValidator()])), ('anchor', wagtail.blocks.CharBlock(form_classname='anchor_link', label='#', max_length=300, required=False)), ('email', wagtail.blocks.EmailBlock(required=False)), ('phone', wagtail.blocks.CharBlock(form_classname='phone_link', label='Phone', max_length=30, required=False)), ('new_window', wagtail.blocks.BooleanBlock(form_classname='new_window_toggle', label='Open in new window', required=False))]))], label='Terms & Conditions for Visual Creator'))], null=True, use_json_field=True),
        ),
    ]

```