Sets a default got Collection.slug to a function that returns a time-based 14-char string (e.g. 391aa8b65cac28, old collections have 24 char slugs, e.g. 5ea06a37ddd0518f90c43fb4).
Fixes https://developer.blender.org/T83409
Currently unique slugs for collections are not enforced (due to the migration process). It would be good to bring the constraint back
Collection slugs actually already had a unique constraint, but enforced per parent collection. This patch changes this constraint enforcing slugs unique in the whole collections table.
Should be unique enough for our purposes, couldn't get collisions after about a dozen attempts like this:
>>> import random >>> from time import time >>> _ = [hex(int(time()*10000000))[2:] for _ in range(10000000)] >>> len(_) == len(set(_)) True
With truncated uuid4 getting collisions is fairly easy even at 10 char:
>>> _ = [uuid4().hex[:10] for _ in range(1000000)] # third try >>> len(_) == len(set(_)) False
