Non-primary key database sequence

AutoField has to have a primary key, but I have a column we want to increment. It’s a kind of account ID that we want to generate, but we don’t want to have them as the primary key as it’s a bit inflexible if we want to change the scheme at some point in the future, and at the moment all our models have UUIDs for PKs, which seems unnecessary to me but it’s what we have.

As we’re running Postgres we should be able to just have an extra identity field and I don’t mind create a new model Field class to do this… I am just wondering if this is going to break something somewhere? Presumably there’s some reason AutoFields have to be the primary key but I couldn’t surface much information up on it or if having a custom field class would bypass these issues.

Does anyone have an idea? Or if there’s a better solution to this problem I’m not thinking of?

We had a similar situation - what we had done was create the SERIAL column directly in the database using SQL, and defined the field in the model as an IntegerField. (If we had to do it again, we’d probably define the field as a custom migration.)