Search code examples
djangoherokudjango-cms

django CMS error cms_urlconfrevision on deployment


I'm trying to deploy a django CMS app to PythonAnywhere or Heroku but I keep getting this error on Heroku:

ProgrammingError at /
relation "cms_urlconfrevision" does not exist
LINE 1: ...sion"."id", "cms_urlconfrevision"."revision" FROM "cms_urlco...

and this error on PythonAnywhere:

OperationalError at /
no such table: cms_urlconfrevision

The app works fine on localhost.

I understand it's a database table missing but I have no idea how to fix it. I tried removing all the migration files and .pyc files and migrated again, I removed the database, I tried migration with --fake. Nothing seems to work.

I'm using

  • django-cms==3.6.0
  • Django==2.1.8

Solution

  • I understand it's a database table missing but I have no idea how to fix it. I tried removing all the migration files and .pyc files and migrated again, I removed the database, I tried migration with --fake. Nothing seems to work.

    Migration files just define what migrations exist. They don't modify your database by themselves. There are two steps here:

    1. Creating migrations with makemigrations. This should only be done on your development machine. By the time your code is being deployed you shouldn't have any model changes that would cause new migrations to be generated.

    2. Applying migrations to your database with migrate. This must be done in development (to update your local database) and also in production (to update your production database).

      On Heroku, you'd run your migrations with

      heroku run python manage.py migrate
      

      I think this is the step you're missing.