Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception while running contenttypes migrate #37

Closed
ghost opened this issue Jun 14, 2018 · 5 comments
Closed

Exception while running contenttypes migrate #37

ghost opened this issue Jun 14, 2018 · 5 comments

Comments

@ghost
Copy link

ghost commented Jun 14, 2018

Subject: Exception while running django migrate

I am getting this exception while running the migrate command. how can i resolve it?

Error logs / results

Running migrations:
  Applying contenttypes.0002_remove_content_type_name...Traceback (most recent call last):
  File "/home/tempuser/enrichai/map-matched-backup/venv3/lib/python3.6/site-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: cannot drop sortkey column "name"

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/tempuser/enrichai/map-matched-backup/venv3/lib/python3.6/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
    utility.execute()
  File "/home/tempuser/enrichai/map-matched-backup/venv3/lib/python3.6/site-packages/django/core/management/__init__.py", line 355, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/tempuser/enrichai/map-matched-backup/venv3/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/tempuser/enrichai/map-matched-backup/venv3/lib/python3.6/site-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/home/tempuser/enrichai/map-matched-backup/venv3/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 204, in handle
    fake_initial=fake_initial,
  File "/home/tempuser/enrichai/map-matched-backup/venv3/lib/python3.6/site-packages/django/db/migrations/executor.py", line 115, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "/home/tempuser/enrichai/map-matched-backup/venv3/lib/python3.6/site-packages/django/db/migrations/executor.py", line 145, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "/home/tempuser/enrichai/map-matched-backup/venv3/lib/python3.6/site-packages/django/db/migrations/executor.py", line 244, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/home/tempuser/enrichai/map-matched-backup/venv3/lib/python3.6/site-packages/django/db/migrations/migration.py", line 129, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/home/tempuser/enrichai/map-matched-backup/venv3/lib/python3.6/site-packages/django/db/migrations/operations/fields.py", line 154, in database_forwards
    schema_editor.remove_field(from_model, from_model._meta.get_field(self.name))
  File "/home/tempuser/enrichai/map-matched-backup/venv3/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 470, in remove_field
    self.execute(sql)
  File "/home/tempuser/enrichai/map-matched-backup/venv3/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 120, in execute
    cursor.execute(sql, params)
  File "/home/tempuser/enrichai/map-matched-backup/venv3/lib/python3.6/site-packages/django/db/backends/utils.py", line 80, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "/home/tempuser/enrichai/map-matched-backup/venv3/lib/python3.6/site-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
  File "/home/tempuser/enrichai/map-matched-backup/venv3/lib/python3.6/site-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/home/tempuser/enrichai/map-matched-backup/venv3/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/home/tempuser/enrichai/map-matched-backup/venv3/lib/python3.6/site-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: cannot drop sortkey column "name"

Environment info

  • OS: UBUNTU 16.04
  • Python version: 3.5
  • Django version: 1.11
  • psycopg2
@Surgo
Copy link
Member

Surgo commented Jun 14, 2018

What is diff of models?
Please more info of your model changes.

@jamespenick
Copy link

I realize this is an old issue, but I ran into the same problem today. In case it helps someone else, I had neglected to specify my Django application when running migrations. In other words:

python manage.py migrate <-- Don't do this
python manage.py migrate app <-- Try this instead

@dre2004
Copy link

dre2004 commented Sep 20, 2019

Is there a fix for this? If you're using the admin site I believe you need to migrate content_types.

To replicate the issue, start a new django app (don't need any models) and run the following:

python manage.py migrate

This will create the tables for the django admin site, content_types and migrations. This fails on the content_types table.

@shimizukawa
Copy link
Member

fixed by #97.

@shimizukawa
Copy link
Member

It has been released https://pypi.org/project/django-redshift-backend/3.0.0/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants