Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Cannot migrate cms back to zero [at least in SQLite] #1192

Closed
kezabelle opened this Issue · 3 comments

3 participants

@kezabelle
 ./manage.py migrate cms

[... does lots of output ...]

$ ./manage.py migrate cms zero
Running migrations for cms:
 - Migrating backwards to zero state.

[... does lots of output ...]

Traceback (most recent call last):
  File "manage.py", line 11, in <module>
    execute_manager(settings)
  File "/path/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/path/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/path/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/path/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "/path/south/management/commands/migrate.py", line 105, in handle
    ignore_ghosts = ignore_ghosts,
  File "/path/south/migration/__init__.py", line 191, in migrate_app
    success = migrator.migrate_many(target, workplan, database)
  File "/path/south/migration/migrators.py", line 221, in migrate_many
    result = migrator.__class__.migrate_many(migrator, target, migrations, database)
  File "/path/south/migration/migrators.py", line 338, in migrate_many
    self.migrate(migration, database)
  File "/path/south/migration/migrators.py", line 125, in migrate
    result = self.run(migration)
  File "/path/south/migration/migrators.py", line 99, in run
    return self.run_migration(migration)
  File "/path/south/migration/migrators.py", line 81, in run_migration
    migration_function()
  File "/path/south/migration/migrators.py", line 57, in <lambda>
    return (lambda: direction(orm))
  File "/path/cms/migrations/0026_finish_placeholder_migration.py", line 30, in backwards
    db.add_column('cms_cmsplugin', 'placeholder', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['cms.CMSPlugin']))
  File "/path/south/db/sqlite3.py", line 29, in add_column
    raise ValueError("You cannot add a null=False column without a default value.")
ValueError: You cannot add a null=False column without a default value.

I can't tell, from the resolution of #213, whether this would come under the same '3rd party issue' wontfix. The same migration (0026) has been fixed before, in #435. I've no idea if it affects other database backends, though it seems like it could.

The fix seems simple: line 27 would have the same problem, were it not for having default=0, which could probably be applied to line 30 too?

Relevant settings

$ ./manage.py diffsettings
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': '/path/to/testdb.sqlite3'
    }
}
CMS_FRONTEND_LANGUAGES = ['en']  ###
CMS_LANGUAGES = (('en', 'English'),)  ###
CMS_LANGUAGE_FALLBACK = False  ###
CMS_MODERATOR = False  ###
CMS_PERMISSION = False  ###
CMS_TEMPLATES = (('base.html', 'Default'),)  ###
INSTALLED_APPS = ['django.contrib.auth', 'django.contrib.contenttypes',
'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages',
'django.contrib.admin', 'django.contrib.admindocs', 'cms', 'menus', 'mptt',
'south', 'sekizai',]

>>> import cms, django
>>> cms.__version__
'2.2' # Actually develop
>>> django.VERSION
(1, 3, 1, 'final', 0)
>>>
@kezabelle

The proposed change (default=0) works fine, but leads to a new instance of the same problem:

File "/path/cms/migrations/0017_author_removed.py", line 19, in backwards
    db.add_column('cms_publicpage', 'author', orm['cms.publicpage:author'])
  File "/path/south/db/sqlite3.py", line 29, in add_column
    raise ValueError("You cannot add a null=False column without a default value.")
ValueError: You cannot add a null=False column without a default value.

Unfortunately, South doesn't document which version was used to create a migration, and I can't find any documentation about the format used there, or how to sort it.

Leaving this open for now, because it'd be nice to have fixed, but it may end up having to be wontfix'd eventually.

@ojii
Collaborator

Not sure this is a WONTFIX, more a lot of work. The migrations are a bit in a worrying state, and it might be wise to just replace the old-style migrations with newer ones. Also as other tickets (#1098) show, there's also other issues with migrations in the CMS. Not to mention the issue of trying to migrate a plugin that is installed after the fact.

The ideal solution in my opinion would still be to somehow squash the migrations together in a single new migration (per "app"). The real hard part here is, how do we get currently migrated installations to that new system?

if anyone wants to tackle this issue (and other south/migrations) issues, that would be highly appreciated!

@digi604
Collaborator

fixed in develop

@digi604 digi604 closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.