django-simple-history
django-simple-history copied to clipboard
It appears the simple-history is incompatible with model_utils.models.UUIDModel
Describe the bug It appears the simple-history is incompatible with model_utils.models.UUIDModel. Despite my best efforts, it attempts to have two primary_key values on the history table always.
To Reproduce Steps to reproduce the behavior:
- Create a basic model that works with Django simple-history and add in the
history = HistoricalRecords()
manager. Verify it is working, - Destroy the prior migration and table and modify your test model to inherit from
model_utils.models.UUIDModel
- Make a new migration and note that it attempts to have two primary_key values on the history table.
- Attempt to migrate and see error
Expected behavior
Should be able to create a history table with a UUID primary key, based off the jazzband model_utils.models.UUIDModel
Environment (please complete the following information):
- OS: ubuntu-latest
- Browser (if applicable): n/a
- Django Simple History Version: 3.0.0
- Django Version: 3.2.13
- Database Version: PostgreSQL
Additional context We want to use both things but are using simple history with regular AI integer PKs until this issue can be fixed.
yes facing the same problem here also with the default django models.uuid.
I know it's stated in the documentation but maybe we should give the option for users to choose their primary key?
Note: regardless of what field type you specify as your history_id field, that field will automatically set primary_key=True and editable=False.
class Meta(TimeStampedModel):
history = HistoricalRecords(inherit=True)
id = SmallUUIDField(default=uuid_default(), editable=False, primary_key=True)
causes an error to be raised
DETAIL: Key (id)=(319a9473-6717-4254-bc03-58e26590ffc9) already exists.```
I think the library was relying on the autoincrement to create different versions of the history.