Search code examples
pythondjangodjango-cms

Switching django-cms project from sqlite to postgres


I'm trying to switch database backends for an existing django-cms project, from sqlite3 to postgresql. When I start with a fresh sqlite database and apply all migrations everything works fine. If I do the same with a fresh postgres database everything appears to go ok but I get the following error when trying to do anything:

django.db.utils.ProgrammingError: relation "cms_urlconfrevision" does not exist 
LINE 1: ...sion"."id", "cms_urlconfrevision"."revision" FROM "cms_urlco...

I get a warning while running runserver that there are unapplied migrations despite the fact that a listing of migrations shows all applied, and running migrate again does nothing (makemigrations also does nothing). The cms_urlconfrevision table exists in the database, with the id and revision fields, so I'm at a loss for where to look further.

Adding versions: django 1.9.7, django-cms 3.4.4


Solution

  • After choosing a new database, first comment out all the other apps you have put in the INSTALLED_APPS. Then makemigration and migrate. If that works then add other apps and create migrations and migrate.

    If still it doesn't work.

    Try to delete all the earlier created migrations from migrations directory in every app. And then again makemigrations and migrate.