Skip to content

Thursday, April 6, 2023

UUIDs everywhere

Jan Peter
origins-mika-baumeister-wpnoqo2plfa-unsplash.jpg

Originally posted on the strackt devlog in April 2023, during the early build. Brought over so the whole journey lives in one place.

Something that has been 'bugging' me from the beginning: all the numeric id's everywhere. Why does it bug me? Good question, but its probably because my mind starts to or tries to recognize these as patterns. Until I migrate:fresh the database and things are reset again.

Anyway, it's one of those things that were on the list to be fixed anyway, because it's a potential security risk anyway and users might deduct certain conclusions based on ids (I certainly do on other sites)

    public function servers()
    {
        return $this->belongsToMany(Server::class, 'server_site', 'server_id', 'site_id')
            ->using(new class extends Pivot {
                use HasUuids;
            });
    }

Thanks to solid tests, the implementation is a breeze. The only thing that needed some attention was the UUID generation in pivot tables without a model. As Laravel is endlessly flexible this neat piece of code quickly fixes that.


What got done

  • Implemented UUIDs everywhere

  • Extended even more tests