You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’m using Postgres with the uuid-ossp extension which provides the following functionality: uuid_generate_v4() which I have created a macro on the schematic builder for:
Blueprint::macro('primaryUuid', function ($field = 'uuid') {
$this->uuid($field)->default(\DB::raw('uuid_generate_v4()'))->primary();
});
This requires the $incrementing property on the model to be true (incrementing is a bad choice for this property on Laravel’s side, it basically means “the database handles it”)
Might I suggest that this model utilises the uuid_generate_v4 method to create the UUID for Postgres if the option is available?
Might it be better to create a macro for creating primary UUID columns and add it to the schema builder which sets a default value for a primary UUID?
If this is something you would want to try I could make a PR for it.
The text was updated successfully, but these errors were encountered:
Hey @willishq thanks for raising this. This is a cool idea but it doesn't fit in with the aims of this package, as it's specific to a particular database. I think this should be it's own package, perhaps with support for other database specific UUID generation too?
I’m using Postgres with the
uuid-ossp
extension which provides the following functionality:uuid_generate_v4()
which I have created a macro on the schematic builder for:This requires the
$incrementing
property on the model to betrue
(incrementing is a bad choice for this property on Laravel’s side, it basically means “the database handles it”)Might I suggest that this model utilises the
uuid_generate_v4
method to create the UUID for Postgres if the option is available?Might it be better to create a macro for creating primary UUID columns and add it to the schema builder which sets a default value for a primary UUID?
If this is something you would want to try I could make a PR for it.
The text was updated successfully, but these errors were encountered: