django - How to convert an Charfield Primary key to AutoField in Postgres -
i have model following in django application
order_id = models.charfield(max_length=120, default=uuid.uuid4, unique=true, primary_key=true) timestamp = models.datetimefield(auto_now_add=true, auto_now=false,null=true) delivery_address = models.charfield(max_length=200, blank=true) order_by = models.foreignkey(user,null=true, blank=true,on_delete=models.cascade); order_description = jsonfield(null=true, blank=true)
i want convert order_id autofield final column order_id = models.autofield(primary_key=true)
encounter following error during migration django.db.utils.programmingerror: operator class "varchar_pattern_ops" not accept data type integer
. searched online not able find proper solution above issue. sorry if question had been asked before. in advance.
django try convert current string values integer , of course can it. need create data migration (look eaxample: data-migrations) , change current values integer, may best way create new columns, , remember if have foreign keys on table, need data migration other tables.
Comments
Post a Comment