I have a legacy Django Application (1.11) which uses UUID as primary key, hence doesn't have an ID field. My DB is postgres
class model_name(models.Model):
.... #model data ...
companyId = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
.... # Other model data
I now need to add a human readable auto-incrementing identifier which will be used by users to refer to the records outside the system.
The challenges are as follows:
- The system can have multiple entries being added simultaneously, so it needs to manage that without collisions
- ideally would need to add this to the save() method because new
- I have around 20000 records already in the database for this model. So whatever method I use, I will need to be able to add values for all previous records.
- I need to start numbering at 100,000
Is there a way to do this (Autofield may not work because its not going to be primary key and i already have n records in the system.) so it will remain consistent?