Skip to content

[5.8] Add the proper columns for a polymorphic table (using uuid for the {$name}_id column)#29289

Merged
taylorotwell merged 2 commits intolaravel:5.8from
diamondobama:5.8
Jul 25, 2019
Merged

[5.8] Add the proper columns for a polymorphic table (using uuid for the {$name}_id column)#29289
taylorotwell merged 2 commits intolaravel:5.8from
diamondobama:5.8

Conversation

@diamondobama
Copy link
Copy Markdown
Contributor

This allows creating polymorphic columns with the id being uuid without the need to manually create individual columns and index them afterward.

@taylorotwell taylorotwell merged commit 46e2d0e into laravel:5.8 Jul 25, 2019
@GrahamCampbell GrahamCampbell changed the title Add the proper columns for a polymorphic table (using uuid for the {$name}_id column) [5.8] Add the proper columns for a polymorphic table (using uuid for the {$name}_id column) Jul 28, 2019
@rjvim
Copy link
Copy Markdown

rjvim commented Jul 21, 2020

Hi,

When we use something like:

   public function commentable()
    {
        return $this->morphTo();
    }

How do you propose to use this relationship when we use uuidMorphs. This relationship is not working as it's expecting id to be an integer in the other table.

@diamondobama
Copy link
Copy Markdown
Contributor Author

diamondobama commented Jul 21, 2020

@rjvim Did you set below in the model you are morphing to?

/**
 * The "type" of the primary key ID.
 *
 * @var string
 */
protected $keyType = 'string';

@rjvim
Copy link
Copy Markdown

rjvim commented Jul 21, 2020

Hi,

I didnt set this one.

But it worked even without it. In the other table, I had to set column type to "uuid".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants