Search code examples
djangopostgresqldjango-databasedjango-datatable

Error while changing database engine to PostgreSQL


I got this error after changing the engine, the database is connected however it figured out my id field is a bigint, yet I specifically set it as a UUID field.

class Cart(models.Model):
id = models.UUIDField(default=uuid.uuid4, primary_key=True)
created_at = models.DateTimeField(auto_now_add=True)

in terminal I get this error:

django.db.utils.ProgrammingError: cannot cast type bigint to uuid
LINE 1: ...LE "store_cart" ALTER COLUMN "id" TYPE uuid USING "id"::uuid

enter image description here


Solution

  • I was the same issues as you, And I fixed it by deleting all previous migrations tables, I hope it will work also for you.