In addition to my primary key (‘id’) i would like to have a additional and uniqe (‘id_numeric’) field which is populated by independently the values of a postgresql sequence.
How can define this and how can i create a suitable migration if the ‘id_numeric’ field is added in subsequence and in addition to the primary key?
My django model looks like this:
class DesiredTenant(models.Model):
_DEFAULT_MINIMUM_PASSWORD_LENGTH: int = 8
class Meta:
verbose_name = "Tenant"
]
id = models.CharField("System-ID", primary_key=True, max_length=63, unique=True,
validators=[ALLOWED_CHARACTERS_REGEX_VALIDATOR],
help_text=f"The system id")
id_numeric = models.PositiveIntegerField("Numeric-System-ID", editable=False,
unique=True, null=False, blank=False)