Repository: django-cms/django-cms

Issue:
Missing migration with Django 1.7 (DjangoCMS 3.0.6, up to 3.0.12)
Starting a project with Django 1.7 and DjangoCMS 3.0.6 will result in Django's `makemigrations` creating another migration file for the `cms` app. You can see the the created migration file here:

http://paste.awesom.eu/ZnyI

This gets annoying when creating custom plugins which then automatically depend on the locally created 0004 `cms` migration: It breaks deployment on a remote machine. My current fix is to manually edit the custom plugins' migration files to depend on the shipped 0003 `cms` migration.

I noticed that Django's migration system is more sensitive to changes than South, so could you please run `makemigrations` on all your cms apps (noticed a similar issue with `djangocms_link`) before the next release? Thanks!



Discussion:
This is a known issue and is resolved in the support/3.0.x branch. You'll need to install from there until 3.0.7 has been released.

```
pip install -e git+https://github.com/divio/django-cms.git@support/3.0.x#egg=django-cms
```

If you are using any of Divio's cms plugins or cmsplugin-filer, you might want to double check that they are all up to date as well. There were many challenges getting the new style migrations working correctly I believe we've got them all sorted out now. However, not everything has been given an official release yet so you may need to install from the git develop branches for some of these.

Sweet as, thanks!

Solved in current support/3.0.x branch about to be released as 3.0.7

Upgraded to Django-cms 3.0.7, still experiencing the same:
KeyError: u"Migration cmsplugin_filer_image.0001_initial dependencies reference nonexistent parent node (u'cms', u'0003_auto_20140926_2347')"

@spout said migration file is shipped. Have you followed Django 1.7 instructions? http://docs.django-cms.org/en/support-3.0.x/upgrade/3.0.6.html#django-1-7-support 

Thanks ! I think it was done, but it was commented in my settings. Solved.

I just installed 3.0.7, but it's still missing (at least) one migration:

```
$ pip show django-cms
---
Name: django-cms
Version: 3.0.7
```

```
$ ./manage.py makemigrations cms
Migrations for 'cms':
  0004_auto_20141201_1231.py:
    - Alter field plugin on aliaspluginmodel
    - Alter field parent on cmsplugin
```

See http://paste.awesom.eu/WcTb for the created file.

what's your settings? Actually the resulting migration is a noop as the fields are exactly the same as the ones created in the initial migration.
`develop.py makemigrations` which is the command used to create migrations for the CMS core does not report any further migration needed

The settings should be this: http://paste.awesom.eu/n5bA (edited to remove private data) .

I would like to add that i usually don't run `makemigrations` without a specific app following. I only stumbled upon this when bootstrapping the project. What does happen regularly though, is Django complaining about missing migrations when running `migrate` (which happens on deployment):

```
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.
```

I am also encountering this issue with Django 1.7 and Django-cms 3.0.9

What's the resulting code of the migration?

``` python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations


class Migration(migrations.Migration):

    dependencies = [
        ('cms', '0003_auto_20140926_2347'),
    ]

    operations = [
        migrations.AlterField(
            model_name='cmsplugin',
            name='plugin_type',
            field=models.CharField(verbose_name='plugin_name', max_length=50, editable=False, db_index=True),
            preserve_default=True,
        ),
        migrations.AlterField(
            model_name='title',
            name='has_url_overwrite',
            field=models.BooleanField(default=False, verbose_name='has url overwrite', db_index=True, editable=False),
            preserve_default=True,
        ),
    ]
```

Tried on a fresh project started with nephila/djangocms-installer and can't reproduce this on 3.0.10.
Django 1.7 is quite sensitive and errs on the safe side generating migration with no real changes.
Possibly some third-party application that for some reason triggers django db migration into thinking a database schema change has occurred

The project I'm encountering this on was also created with djangocms-installer, and so far is quite simple. I believe I first encountered this error upon adding my first custom CMS plugin.

I updated my cms version to 3.0.10 and am still experiencing the error.

I'm experiencing the same issue on djangocms 3.0.10 running on django 1.7.4, but originating from the djangocms_blog plugin. 

```
KeyError: u"Migration djangocms_blog.0001_initial dependencies reference nonexistent parent node (u'cms', u'0003_auto_20140926_2347')"
```

That is a different, albeit similar, problem.

Is there any opposition to simply adding the `0004_auto` migration to the project?

I'm definitely not keen adding a migration which can't be reproduced on stock django CMS project: we need to fix the issue that triggers the new (unneeded) migration, instead

The verbose names were changed in the migrations so they are out of sync with the models. That is why there are spurious migrations. I have a fix coming in the next few seconds but read on for background.

In 3.0.10, the 0002 migration has `verbose_name='has URL overwrite'` which was changed in https://github.com/divio/django-cms/commit/89a95b7393119fdeecff9c16f9757482fdf46e00 but the model's verbose_name is 'has url overwrite' (all lower case).

https://github.com/divio/django-cms/commit/3ffd7e6e60ab2d2ac69431c70a8d4db45ede0b69 changed the verbose name for CMSPlugin.plugin_type field from 'plugin_name' to 'plugin name'.


Resolving patch:
diff --git a/cms/migrations_django/0001_initial.py b/cms/migrations_django/0001_initial.py
--- a/cms/migrations_django/0001_initial.py
+++ b/cms/migrations_django/0001_initial.py
@@ -26,7 +26,7 @@ class Migration(migrations.Migration):
                 ('id', models.AutoField(primary_key=True, verbose_name='ID', auto_created=True, serialize=False)),
                 ('position', models.PositiveSmallIntegerField(null=True, editable=False, blank=True, verbose_name='position')),
                 ('language', models.CharField(db_index=True, max_length=15, verbose_name="language", editable=False)),
-                ('plugin_type', models.CharField(verbose_name='plugin name', max_length=50, editable=False, db_index=True)),
+                ('plugin_type', models.CharField(verbose_name='plugin_name', max_length=50, editable=False, db_index=True)),
                 ('creation_date', models.DateTimeField(default=django.utils.timezone.now, verbose_name='creation date', editable=False)),
                 ('changed_date', models.DateTimeField(auto_now=True)),
                 ('level', models.PositiveIntegerField(db_index=True, editable=False)),
diff --git a/cms/migrations_django/0002_auto_20140816_1918.py b/cms/migrations_django/0002_auto_20140816_1918.py
--- a/cms/migrations_django/0002_auto_20140816_1918.py
+++ b/cms/migrations_django/0002_auto_20140816_1918.py
@@ -125,7 +125,7 @@ class Migration(migrations.Migration):
                 ('meta_description', models.TextField(max_length=155, null=True, help_text='The text displayed in search engines.', blank=True, verbose_name='description')),
                 ('slug', models.SlugField(max_length=255, verbose_name='slug')),
                 ('path', models.CharField(db_index=True, max_length=255, verbose_name='Path')),
-                ('has_url_overwrite', models.BooleanField(default=False, verbose_name='has URL overwrite', db_index=True, editable=False)),
+                ('has_url_overwrite', models.BooleanField(default=False, verbose_name='has url overwrite', db_index=True, editable=False)),
                 ('redirect', models.CharField(max_length=255, null=True, blank=True, verbose_name='redirect')),
                 ('creation_date', models.DateTimeField(default=django.utils.timezone.now, verbose_name='creation date', editable=False)),
                 ('published', models.BooleanField(default=False, verbose_name='is published')),


Test patch: