Opened 9 years ago

Closed 8 years ago

#26586 closed Bug (wontfix)

makemigrations does not detect custom field subclassing change

Reported by: Phil Krylov Owned by: Baylee Feore
Component: Migrations Version: 1.9
Severity: Normal Keywords: migrations, custom fields
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Tobin Brown)

Example:

class MyLongTextField(models.CharField):
    def __init__(self, *args, **kwargs):
        kwargs["max_length"] = 2000
        super(MyLongTextField, self).__init__(*args, **kwargs)

After changing this to

class MyLongTextField(models.TextField):
    def __init__(self, *args, **kwargs):
        kwargs["max_length"] = 2000
        super(MyLongTextField, self).__init__(*args, **kwargs)

manage.py makemigrations detects no changes.

Change History (6)

comment:1 by Tim Graham, 9 years ago

Triage Stage: UnreviewedAccepted

I'm not sure how to handle this.

comment:2 by Phil Krylov, 9 years ago

I think that expected behaviour is to generate an ALTER TABLE table_name ALTER COLUMN column_name TYPE TEXT migration operation. However, I'm not familiar enough with migration internals to predict what it takes to detect a change like this.

comment:3 by Tobin Brown, 9 years ago

Description: modified (diff)

comment:4 by Baylee Feore, 8 years ago

Owner: changed from nobody to Baylee Feore
Status: newassigned

comment:5 by Baylee Feore, 8 years ago

After discussion with Markus at PyCon sprints 2016:

This isn't possible. The closest we get is here, where we could add a check for get_internal_type() of the two fields. But that won't work because the old state and new state are dynamically generated from the field definition in the migration files. The only way to handle this would be if we saved internal type as part of the migrations.

Propose closing this in favor of adding documentation in #26702

comment:6 by Tim Graham, 8 years ago

Resolution: wontfix
Status: assignedclosed

For future reference, it would probably be fine to reclassify this ticket as a documentation issue, but since you've already created another issue, I'll close this.

Note: See TracTickets for help on using tickets.
Back to Top