Commit b29f8a88 authored by Taylor Otwell's avatar Taylor Otwell

add default value for index names.

parent b73a60de
......@@ -79,7 +79,7 @@ class Table {
* @param string $name
* @return Fluent
*/
public function unique($columns, $name)
public function unique($columns, $name = null)
{
return $this->key(__FUNCTION__, $columns, $name);
}
......@@ -91,7 +91,7 @@ class Table {
* @param string $name
* @return Fluent
*/
public function fulltext($columns, $name)
public function fulltext($columns, $name = null)
{
return $this->key(__FUNCTION__, $columns, $name);
}
......@@ -103,7 +103,7 @@ class Table {
* @param string $name
* @return Fluent
*/
public function index($columns, $name)
public function index($columns, $name = null)
{
return $this->key(__FUNCTION__, $columns, $name);
}
......@@ -118,9 +118,17 @@ class Table {
*/
public function key($type, $columns, $name)
{
$parameters = array('name' => $name, 'columns' => (array) $columns);
$columns = (array) $columns;
return $this->command($type, $parameters);
// If no index name was specified, we will concatenate the columns and
// append the index type to the name to generate a unique name for
// the index that can be used when dropping indexes.
if (is_null($name))
{
$name = implode('_', $columns).'_'.$type;
}
return $this->command($type, compact('name', 'columns'));
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment