#23256: Changes in Meta class don't detected after "makemigrations"
----------------------------+--------------------
Reporter: humitos | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------
I found that adding "permissions" to the Meta class into a model and then
removing these Meta class makes django migration system to be confused and
it tries to create a new migrations with an empty "options" dictionary
each time that "makemigrations" is ran.
Steps to reproduce:
1. Create a new project
1. Create a new app
1. Install the app in the project
1. Run "migrate"
1. Create a new model
{{{
class MyModel(models.Model):
name = models.CharField(max_length=32)
}}}
1. Run "makemigrations"
1. Run "migrate"
1. Add Meta class to MyModel
{{{
class MyModel(models.Model):
name = models.CharField(max_length=32)
class Meta:
permissions = (
('use_mymodel', 'Use this model'),
)
}}}
1. Run "makemigrations" and you will get the "options" attribute in the
migration file
{{{
operations = [
migrations.AlterModelOptions(
name='mymodel',
options={'permissions': ((b'use_mymodel', b'Use this
model'),)},
),
]
}}}
1. Run "migrate"
1. Remove Meta class from MyModel
{{{
class MyModel(models.Model):
name = models.CharField(max_length=32)
}}}
1. Run "makemigratios" and you will get an empty "options" dictionary
{{{
operations = [
migrations.AlterModelOptions(
name='mymodel',
options={},
),
]
}}}
1. Run "migrate"
1. Run again "migrate" and you will get this message:
{{{
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.
}}}
1. Run "makemigrations" again and the same migration file is created with
empty "options" dictionary
{{{
class Migration(migrations.Migration):
dependencies = [
('myapp', '0002_auto_20140807_1242'),
]
operations = [
migrations.AlterModelOptions(
name='mymodel',
options={},
),
]
}}}
Now, every time you run "migrate" it will tells you that "your models have
changes that are not yet reflected in a migration" and after running
"makemigrations" you will get the same migrations every time. So, you
never get to a state valid for Django Migration System.
I'm attaching a project with all the steps already done, from where you
just simply can run "migrate" and "makemigrations" many times to see what
I described here.
--
Ticket URL: <https://code.djangoproject.com/ticket/23256>
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/050.9cb8edeb566fc8121277833b2cce16a0%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.