增加addNullableMorphs

This commit is contained in:
yunwuxin 2017-03-28 12:43:45 +08:00
parent 98d002b9a9
commit 238c265822

View File

@ -84,6 +84,14 @@ class Table extends \Phinx\Db\Table
return $this; return $this;
} }
public function addNullableMorphs($name, $indexName = null)
{
$this->addColumn(Column::unsignedInteger("{$name}_id")->setNullable());
$this->addColumn(Column::string("{$name}_type")->setNullable());
$this->addIndex(["{$name}_id", "{$name}_type"], ['name' => $indexName]);
return $this;
}
/** /**
* @param string $createdAtColumnName * @param string $createdAtColumnName
* @param string $updatedAtColumnName * @param string $updatedAtColumnName