Skip to content

Commit

Permalink
swap the index order of morph type and id (#21693)
Browse files Browse the repository at this point in the history
It can be utilize the index when query the type by using "WHERE type = ?",
also "WHERE type IN (?)"
  • Loading branch information
eddiclin authored and taylorotwell committed Oct 17, 2017
1 parent 6ca6854 commit d15ad0f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Illuminate/Database/Schema/Blueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -1033,11 +1033,11 @@ public function multiPolygon($column)
*/
public function morphs($name, $indexName = null)
{
$this->unsignedInteger("{$name}_id");

$this->string("{$name}_type");

$this->index(["{$name}_id", "{$name}_type"], $indexName);
$this->unsignedInteger("{$name}_id");

$this->index(["{$name}_type", "{$name}_id"], $indexName);
}

/**
Expand All @@ -1049,11 +1049,11 @@ public function morphs($name, $indexName = null)
*/
public function nullableMorphs($name, $indexName = null)
{
$this->unsignedInteger("{$name}_id")->nullable();

$this->string("{$name}_type")->nullable();

$this->index(["{$name}_id", "{$name}_type"], $indexName);
$this->unsignedInteger("{$name}_id")->nullable();

$this->index(["{$name}_type", "{$name}_id"], $indexName);
}

/**
Expand Down

0 comments on commit d15ad0f

Please sign in to comment.