Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#22863 closed Cleanup/optimization (fixed)

Document that changing model options unrelated to the database will create migrations

Reported by: davidray Owned by: nobody
Component: Migrations Version: 1.7-beta-2
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Django 1.7b4 tag

Steps to reproduce:

  • Create initial migrations for app
  • drop and recreate database
  • Run python manage.py migrate
  • Update a model field's verbose_name
  • Run python manage.py migrate

Output is as follows:

Running migrations:
  No migrations needed.
  Your models have changes that are not yet reflected in a migration, and so won't be applied.
  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.
  • Run python manage.py makemigrations

Generates an AlterField migration:

# encoding: utf8
from __future__ import unicode_literals

from django.db import models, migrations


class Migration(migrations.Migration):

    dependencies = [
        ('myapp', '0001_initial'),
    ]

    operations = [
        migrations.AlterField(
            model_name='mymodel',
            name='myfield',
            field=models.ForeignKey(verbose_name='my verbose name', to_field='id', to='myapp.MyModel'),
        ),
    ]

I did not think that a modification to verbose_name would necessitate a migration.

Change History (6)

comment:1 by Tim Graham, 10 years ago

Component: MigrationsDocumentation
Summary: Adding/Editing Model field verbose_name triggers a need for a migrationDocument that changing model options unrelated to the database will create migrations
Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization

This is by design, see #22837. As it's becoming a FAQ, we should improve the documentation.

comment:2 by davidray, 10 years ago

Is this really purely a documentation issue? The management command outputs antithetical feedback in this case:

  No migrations needed.

followed by:

  Your models have changes that are not yet reflected in a migration, and so won't be applied.
  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.

comment:3 by Tim Graham, 10 years ago

Component: DocumentationMigrations
Severity: NormalRelease blocker

Sorry, I didn't read closely enough, that does seem odd.

comment:4 by Andrew Godwin, 10 years ago

That output is the same no matter what options you change - it means:

  • No migrations are needed to run
  • You've got changes, so you need to run makemigrations

We added this as a hint to people who were just running migrate and getting confused. I'll update the message to be less confusing and add a docs paragraph about makemigrations and non-database-affecting parameters.

Version 0, edited 10 years ago by Andrew Godwin (next)

comment:5 by Andrew Godwin <andrew@…>, 10 years ago

Resolution: fixed
Status: newclosed

In 9f4852f649fad459a451995c4a17a7d8db5972c9:

Fixed #22863: Improve clarity of makemigrations for non-db params

comment:6 by Andrew Godwin <andrew@…>, 10 years ago

In bfe5f72c7ee4ecec374af9a52c320c019abfc338:

[1.7.x] Fixed #22863: Improve clarity of makemigrations for non-db params

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