divio/django-cms — Issue #1116: Migration fails with MySQL: ValueError: Cannot find a PRIMARY KEY constraint on table cmsplugin_picturepublic
Author: sylvainblot
Created: 2011-12-12 21:43:35+00:00
State: open

Can't migrate django-cms using MySQL with MYISAM or INNODB as engine. The output:

Python 2.7
mysqld Ver 5.5.15
django-cms 2.2rc3

```
./manage.py migrate cms
Running migrations for cms:
- Migrating forwards to 0035_auto__add_field_globalpagepermission_can_view__add_field_pagepermissio.
> cms:0001_initial
> picture:0001_initial
> picture:0002_link_rename
> picture:0003_freeze
> cms:0002_auto_start
> cms:0003_remove_placeholder
> cms:0004_textobjects
> cms:0005_mptt_added_to_plugins
> cms:0006_apphook
> cms:0007_apphook_longer
> cms:0008_redirects
> cms:0009_added_meta_fields
> cms:0010_5char_language
> cms:0011_title_overwrites
> cms:0012_publisher
> picture:0004_publisher
> picture:0005_table_rename
! Error found during real run of migration! Aborting.

! Since you have a database that does not support running
! schema-altering statements in transactions, we have had
! to leave it in an interim state between migrations.

! You *might* be able to recover with: = RENAME TABLE `cmsplugin_picture` TO `picture_picture`; []
= RENAME TABLE `cmsplugin_picturepublic` TO `picture_publicpicture`; []

! The South developers regret this has happened, and would
! like to gently persuade you to consider a slightly
! easier-to-deal-with DBMS.
! NOTE: The error which caused the migration to fail is further up.
Traceback (most recent call last):
File "./manage.py", line 14, in
execute_manager(settings)
File "/Library/Python/2.7/site-packages/Django-1.3-py2.7.egg/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/Library/Python/2.7/site-packages/Django-1.3-py2.7.egg/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.7/site-packages/Django-1.3-py2.7.egg/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Library/Python/2.7/site-packages/Django-1.3-py2.7.egg/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/Library/Python/2.7/site-packages/South-0.7.3-py2.7.egg/south/management/commands/migrate.py", line 105, in handle
ignore_ghosts = ignore_ghosts,
File "/Library/Python/2.7/site-packages/South-0.7.3-py2.7.egg/south/migration/__init__.py", line 191, in migrate_app
success = migrator.migrate_many(target, workplan, database)
File "/Library/Python/2.7/site-packages/South-0.7.3-py2.7.egg/south/migration/migrators.py", line 221, in migrate_many
result = migrator.__class__.migrate_many(migrator, target, migrations, database)
File "/Library/Python/2.7/site-packages/South-0.7.3-py2.7.egg/south/migration/migrators.py", line 292, in migrate_many
result = self.migrate(migration, database)
File "/Library/Python/2.7/site-packages/South-0.7.3-py2.7.egg/south/migration/migrators.py", line 125, in migrate
result = self.run(migration)
File "/Library/Python/2.7/site-packages/South-0.7.3-py2.7.egg/south/migration/migrators.py", line 99, in run
return self.run_migration(migration)
File "/Library/Python/2.7/site-packages/South-0.7.3-py2.7.egg/south/migration/migrators.py", line 81, in run_migration
migration_function()
File "/Library/Python/2.7/site-packages/South-0.7.3-py2.7.egg/south/migration/migrators.py", line 57, in
return (lambda: direction(orm))
File "/Users/sylvain/Documents/Entreprise/sources/Django-Projects/karmapolis_before_new_voting/cms/plugins/picture/migrations/0005_table_rename.py", line 18, in forwards
db.drop_primary_key("cmsplugin_picturepublic")
File "/Library/Python/2.7/site-packages/South-0.7.3-py2.7.egg/south/db/generic.py", line 24, in func
return getattr(self, attrname)(*args, **kwds)
File "/Library/Python/2.7/site-packages/South-0.7.3-py2.7.egg/south/db/generic.py", line 721, in delete_primary_key
raise ValueError("Cannot find a PRIMARY KEY constraint on table %s" % (table_name,))
ValueError: Cannot find a PRIMARY KEY constraint on table cmsplugin_picturepublic
```