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

django.db.utils.ProgrammingError: column "uuid" is of type uuid but default expression is of type integer #53

Open
ninajlu opened this issue Feb 1, 2015 · 2 comments

Comments

@ninajlu
Copy link

ninajlu commented Feb 1, 2015

I tried to push to heroku but got the following error:
Applying accounts.0004_group_uuid...Traceback (most recent call last):
File "manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/init.py", line 385, in execute_from_command_line
utility.execute()
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/init.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(_args, *_options.dict)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute
output = self.handle(_args, *_options)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 161, in handle
executor.migrate(targets, plan, fake=options.get("fake", False))
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/migrations/executor.py", line 68, in migrate
self.apply_migration(migration, fake=fake)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/migrations/executor.py", line 102, in apply_migration
migration.apply(project_state, schema_editor)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/migrations/migration.py", line 108, in apply
operation.database_forwards(self.app_label, schema_editor, project_state, new_state)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/migrations/operations/fields.py", line 37, in database_forwards
field,
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/schema.py", line 378, in add_field
self.execute(sql, params)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/schema.py", line 102, in execute
cursor.execute(sql, params)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/utils.py", line 81, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/utils.py", line 94, in exit
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: column "uuid" is of type uuid but default expression is of type integer
HINT: You will need to rewrite or cast the expression.

Any idea how to fix this?

@glynjackson
Copy link

I ended up here when I Googled the same problem. The answer is that you have old migrations which refer to the int PK before you made the change to use a UUID. In your case the problem seems to be in accounts.0004_group_uuid migration. Just swap this out and it should work.

@bhattraideb
Copy link

I Had same issue. The fix is to delete the old migrations, recreate and migrate.

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

No branches or pull requests

3 participants