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

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -