diff --git a/src/Command/AbstractCommand.php b/src/Command/AbstractCommand.php index 2a04d05b3..b2036c2f2 100644 --- a/src/Command/AbstractCommand.php +++ b/src/Command/AbstractCommand.php @@ -11,6 +11,7 @@ use Yiisoft\Db\Query\Data\DataReaderInterface; use Yiisoft\Db\Query\QueryInterface; use Yiisoft\Db\QueryBuilder\QueryBuilderInterface; +use Yiisoft\Db\Schema\Builder\ColumnInterface; use function explode; use function get_resource_type; @@ -188,7 +189,7 @@ public function addUnique(string $table, string $name, array|string $columns): s return $this->setSql($sql)->requireTableSchemaRefresh($table); } - public function alterColumn(string $table, string $column, string $type): static + public function alterColumn(string $table, string $column, string|ColumnInterface $type): static { $sql = $this->getQueryBuilder()->alterColumn($table, $column, $type); return $this->setSql($sql)->requireTableSchemaRefresh($table); diff --git a/src/Command/CommandInterface.php b/src/Command/CommandInterface.php index 55565f526..b7d9124e1 100644 --- a/src/Command/CommandInterface.php +++ b/src/Command/CommandInterface.php @@ -14,6 +14,7 @@ use Yiisoft\Db\Exception\NotSupportedException; use Yiisoft\Db\Query\Data\DataReaderInterface; use Yiisoft\Db\Query\QueryInterface; +use Yiisoft\Db\Schema\Builder\ColumnInterface; /** * This interface represents a database command, such as a `SELECT`, `INSERT`, `UPDATE`, or `DELETE` statement. @@ -138,13 +139,13 @@ public function addPrimaryKey(string $table, string $name, array|string $columns * * @param string $table The table whose column is to change. * @param string $column The name of the column to change. - * @param string $type The column type. {@see QueryBuilder::getColumnType()} will be called to convert the give - * column type to the physical one. For example, `string` will be converted as `varchar(255)`, and `string not null` - * becomes `varchar(255) not null`. + * @param string|ColumnInterface $type The column type. {@see QueryBuilder::getColumnType()} will be called to + * convert the give column type to the physical one. For example, `string` will be converted as `varchar(255)`, and + * `string not null` becomes `varchar(255) not null`. * * Note: The method will quote the `table` and `column` parameters before using them in the generated SQL. */ - public function alterColumn(string $table, string $column, string $type): static; + public function alterColumn(string $table, string $column, string|ColumnInterface $type): static; /** * Creates a batch INSERT command.