#27928: Gratuitous ALTER COLUMN statements generated for adding blank=True
---------------------------------------------+------------------------
Reporter: Christophe Pettus | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.10
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------------+------------------------
The migration framework, when changing blank=False to blank=True on a
statement with null=False, generates gratuitous `ALTER COLUMN ... ADD
DEFAULT ''` and `ALTER COLUMN DROP DEFAULT` SQL statements. Example:
{{{
class Item(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4,
editable=False)
title = models.CharField(max_length=50, blank=True) # blank=True
added where not previously present
}}}
generates, from `sqlmigration`:
{{{
BEGIN;
--
-- Alter field title on item
--
ALTER TABLE "news_item" ALTER COLUMN "title" SET DEFAULT '';
ALTER TABLE "news_item" ALTER COLUMN "title" DROP DEFAULT;
COMMIT;
}}}
Besides being slightly messy, this can create unexpected locking behavior.
--
Ticket URL: <https://code.djangoproject.com/ticket/27928>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/046.1cc81a9eeb89d6fd234ae53d2dfc2713%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.