Django, legacy PostgreSQL database, multiple primary keys

I suppose that question as old as it possibly could be, but I still have a hope that maybe someone has found some magical solution.

Everything is simple, I have a database (postgresql) with small table as an example, with already existing field with Primary key:

enter image description here

My goal is to add an ID field as a second primary key. My Model looks like this:

class CdcConn(models.Model):
    id = models.BigAutoField(primary_key=True)
    conn_type = models.CharField(max_length=128, blank=True, null=True)
    conn_name = models.CharField(max_length=128)

    class Meta:
        managed = True
        db_table = 'cdc_conn'

After migration the result output is:

django.db.utils.ProgrammingError: multiple primary keys for table "cdc_conn" are not allowed

Tried many options, unique_together, constraints, some additional modules such as django-viewflow, and so on. The issue is about 15 years old, documentation says that composite pk are not allowed, but still, I can't believe that such powerful tool as Django just can't handle that simple operation.

Any thoughts would be highly appreciated.

Back to Top