﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
34984	Adding a field with default crashes for models with GeneratedField on SQLite.	Sarah Boyce	Sarah Boyce	"I added a non-nullable field (in example `new_field_temporary_default`) to a model containing a GeneratedField and in my migration prompt I added a one-off default. I am using SQLite.

Model 

{{{
class Article(models.Model):
    created_at = models.DateTimeField(db_default=Now())
    title = models.CharField(max_length=300)
    slug = models.GeneratedField(
        expression=Lower(Replace(F(""title""), Value("" ""), Value(""-""))),
        db_persist=True,
        unique=True,
    )
    new_field_temporary_default = models.TextField()  # This field added after table was created

}}}


Generated migration:
{{{
# Generated by Django 5.0b1 on 2023-11-21 12:52

from django.db import migrations, models


class Migration(migrations.Migration):
    dependencies = [
        (""blog"", ""0001_initial""),
    ]

    operations = [
        migrations.AddField(
            model_name=""article"",
            name=""new_field_temporary_default"",
            field=models.TextField(default=""Temp default""),
            preserve_default=False,
        ),
    ]

}}}

This failed to migrate with the error

{{{
    return super().execute(query, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django.db.utils.OperationalError: cannot INSERT into generated column ""slug""

}}}


Not certain if this is an issue. Thought I should raise."	Bug	closed	Database layer (models, ORM)	5.0	Release blocker	fixed	sqlite		Ready for checkin	1	0	0	0	0	0
