After upgrading django cms from version 2.4.3 to 3.0.11 (currently it's 3.0.12) I have realised that some models are "out of sync" with its database tables. For example:
class ProjectPagePluginModel(cmsPlugin):
"""
CMS project plugin model.
"""
project = models.ForeignKey(Project, on_delete=CASCADE)
max_occurrences = models.PositiveIntegerField(default=0)
def __unicode__(self):
return self.get_plugin_name()
>>> ProjectPagePluginModel.objects.all()
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/var/www/cms/venv2.7.5.up/lib/python2.7/site-packages/django/db/models/query.py", line 71, in __repr__
data = list(self[:REPR_OUTPUT_SIZE + 1])
File "/var/www/cms/venv2.7.5.up/lib/python2.7/site-packages/django/db/models/query.py", line 96, in __iter__
self._fetch_all()
File "/var/www/cms/venv2.7.5.up/lib/python2.7/site-packages/django/db/models/query.py", line 857, in _fetch_all
self._result_cache = list(self.iterator())
File "/var/www/cms/venv2.7.5.up/lib/python2.7/site-packages/django/db/models/query.py", line 220, in iterator
for row in compiler.results_iter():
File "/var/www/cms/venv2.7.5.up/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 713, in results_iter
for rows in self.execute_sql(MULTI):
File "/var/www/cms/venv2.7.5.up/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 786, in execute_sql
cursor.execute(sql, params)
File "/var/www/cms/venv2.7.5.up/lib/python2.7/site-packages/django/db/backends/util.py", line 53, in execute
return self.cursor.execute(sql, params)
File "/var/www/cms/venv2.7.5.up/lib/python2.7/site-packages/django/db/utils.py", line 99, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/var/www/cms/venv2.7.5.up/lib/python2.7/site-packages/django/db/backends/util.py", line 53, in execute
return self.cursor.execute(sql, params)
ProgrammingError: relation "project_projectpagepluginmodel" does not exist
LINE 1: ...ct_projectpagepluginmodel"."max_occurrences" FROM "project_p...
On the other hand, manage.py syncdb doesn't seem to help. Any idea?
$ python manage.py syncdb
Syncing...
Creating tables ...
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)
Synced:
> [etc.]
Not synced (use migrations):
- [etc.]
- project
Update: neither does manage.py migrate.
Update 2:
Some step of my migration went wrong, I have found the information I had lost.
First, I went into postgresql shell to find out where this plugin information was:
unicms2=> select * from information_schema.tables where table_name like '%projectpage%';
table_catalog | table_schema | table_name | table_type | self_referencing_column_name | reference_generation | user_defined_type_catalog | user_defined_type_schema | user_defined_type_name | is_insertable_into | is_typed | commit_action
---------------+--------------+----------------------------------+------------+------------------------------+----------------------+---------------------------+--------------------------+------------------------+--------------------+----------+---------------
unicms2 | public | cmsplugin_projectpagepluginmodel | BASE TABLE | | | | | | YES | NO |
(1 row)
unicms2=> select count(*) from cmsplugin_projectpagepluginmodel;
count
-------
39180
(1 row)
Then, I went into the django shell to rename the table using [south][1].
>>> from south.db import db
>>> db.rename_table('cmsplugin_projectpagepluginmodel', 'project_projectpagepluginmodel')
I thought this would work, but then I started getting run time errors:
ProgrammingError: relation "cmsplugin_projectpagepluginmodel" does not exist
LINE 1: ...in_projectpagepluginmodel"."max_occurrences" FROM "cmsplugin...