Shai Berger
unread,Sep 21, 2014, 2:00:06 PM9/21/14Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django-d...@googlegroups.com
Hi,
I'm looking into the details of migrations a little, and I ran into this
issue.
I have two migrations: The first creates a model, the second adds another
model and a field to the first model. I'd expect squashmigrations to patch the
AddField into the first CreateModel, but it finds "No optimizations possible".
What am I missing?
Thanks,
Shai.
===============
0001_initial.py
===============
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
]
operations = [
migrations.CreateModel(
name='Knight',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False,
auto_created=True, primary_key=True)),
('name', models.CharField(max_length=100)),
('of_the_round_table', models.BooleanField(default=None)),
],
options={
},
bases=(models.Model,),
),
]
==========================
0002_auto_20140920_1610.py
==========================
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('tut', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Quest',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False,
auto_created=True, primary_key=True)),
('name', models.CharField(max_length=100)),
('knights', models.ManyToManyField(to='tut.Knight')),
],
options={
},
bases=(models.Model,),
),
migrations.AddField(
model_name='knight',
name='owner',
field=models.ForeignKey(to=settings.AUTH_USER_MODEL, null=True),
preserve_default=True,
),
]