Use uuid everywhere
Since we want to federate, we need reliable ids for all our resources.
Involved apps
-
playlists -
users -
music -
favorites -
radios -
requests -
history
(Basically, everything that is exposed via the API).
User is a good app to start, it only has one model.
Proposed workflow
- One MR per app
- Add the uuid field to every model in the app
- Generate the migration with `python manage.py makemigrations
- Add some really basic tests to ensure serializers of the app includes the uuid fields in a read-only mode
- Submit the MR and be happy :)
Actually using those uuid in place of our incremental ids will take place once all apps are updated.
Typical serializer test
# tests/app/test_serializers.py
import pytest
from funkwhale_api.app import serializers
@pytest.mark.parametrize('model, serializerclass', [
('app.Model1', serializers.Model1Serializer),
('app.Model2', serizalizers.Model2Serializers),
])
def test_serializer_includes_uuid_readonly(model, serializer_class, nodb_factories):
obj = nodb_factories[model]()
assert obj.uuid is not None
serializer = serializer_class(obj)
assert serializer.data['uuid'] == obj.uuid
assert 'uuid' in serializer_class._meta.read_only_fields