techmatters / terraso-backend

A Django project that powers the backend of Terraso platform.
GNU Affero General Public License v3.0
21 stars 4 forks source link

fix: have Soil ID cache use BaseModel #1433

Closed paulschreiber closed 1 month ago

paulschreiber commented 1 month ago

Description

Have Soil ID cache use BaseModel. This gives us a date so we can delete stale entries.

I tried migrating the data, but got key errors:

django.db.utils.IntegrityError: duplicate key value violates unique constraint "coordinate_index" DETAIL:  Key (latitude, longitude)=(37.831516, -122.40759) already exists.

so I deleted it instead.

This also avoids the uuids needing to be generated using Python code and migrated in three steps. See https://stackoverflow.com/questions/35281003/django-migration-with-uuid-field-generates-duplicated-values