Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postgres / uuid-ossp extension #4

Closed
willishq opened this issue Jun 25, 2019 · 1 comment
Closed

Postgres / uuid-ossp extension #4

willishq opened this issue Jun 25, 2019 · 1 comment
Labels
wontfix This will not be worked on

Comments

@willishq
Copy link

willishq commented Jun 25, 2019

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.

@matthew-inamdar
Copy link
Member

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?

@matthew-inamdar matthew-inamdar added the wontfix This will not be worked on label Jun 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Development

No branches or pull requests

2 participants