django-uuidfield icon indicating copy to clipboard operation
django-uuidfield copied to clipboard

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

Open ninajlu opened this issue 11 years ago • 2 comments

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?

ninajlu avatar Feb 01 '15 03:02 ninajlu

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.

glynjackson avatar Aug 20 '15 14:08 glynjackson

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

bhattraideb avatar Mar 26 '22 11:03 bhattraideb