diff --git a/CHANGELOG.md b/CHANGELOG.md index 0514f344..6df13e45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ - Enh #274: Refactor for compatibility with `yiisoft/db` package (@Tigrov) - Bug #277: Fix when there is a namespace but the directory does not exist (@Tigrov) - Chg #279: Use `ColumnBuilder` class to create table column definitions (@Tigrov) -- Enh #282: Remove `ColumnInterface` (@Tigrov) +- Enh #282, #283: Adapt to Yii DB changes (@Tigrov) ## 1.2.0 November 27, 2024 diff --git a/src/AbstractMigrationBuilder.php b/src/AbstractMigrationBuilder.php index be2b5014..e670bdab 100644 --- a/src/AbstractMigrationBuilder.php +++ b/src/AbstractMigrationBuilder.php @@ -5,11 +5,11 @@ namespace Yiisoft\Db\Migration; use Yiisoft\Db\Schema\Column\ColumnBuilder; -use Yiisoft\Db\Schema\Column\ColumnSchemaInterface; +use Yiisoft\Db\Schema\Column\ColumnInterface; use Yiisoft\Db\Schema\SchemaInterface; /** - * AbstractMigrationBuilder contains shortcut methods to create instances of {@see ColumnSchemaInterface}. + * AbstractMigrationBuilder contains shortcut methods to create instances of {@see ColumnInterface}. * * These can be used in database migrations to define database schema types using a PHP interface. This is useful to * define a schema in a DBMS independent way so that the application may run on different DBMS the same way. @@ -45,11 +45,11 @@ public function __construct(private SchemaInterface $schema) * * This parameter will be ignored if not supported by the DBMS. * - * @return ColumnSchemaInterface The column instance which can be further customized. + * @return ColumnInterface The column instance which can be further customized. * * @deprecated Use {@see ColumnBuilder::bigint()} instead. Will be removed in 2.0.0. */ - public function bigInteger(int $length = null): ColumnSchemaInterface + public function bigInteger(int $length = null): ColumnInterface { return ColumnBuilder::bigint($length); } @@ -61,11 +61,11 @@ public function bigInteger(int $length = null): ColumnSchemaInterface * * This parameter will be ignored if not supported by the DBMS. * - * @return ColumnSchemaInterface The column instance which can be further customized. + * @return ColumnInterface The column instance which can be further customized. * * @deprecated Use {@see ColumnBuilder::bigPrimaryKey()} instead. Will be removed in 2.0.0. */ - public function bigPrimaryKey(int $length = null): ColumnSchemaInterface + public function bigPrimaryKey(int $length = null): ColumnInterface { return ColumnBuilder::bigPrimaryKey()->size($length); } @@ -75,11 +75,11 @@ public function bigPrimaryKey(int $length = null): ColumnSchemaInterface * * This parameter will be ignored if not supported by the DBMS. * - * @return ColumnSchemaInterface The column instance which can be further customized. + * @return ColumnInterface The column instance which can be further customized. * * @deprecated Use {@see ColumnBuilder::uuidPrimaryKey()} instead. Will be removed in 2.0.0. */ - public function uuidPrimaryKey(): ColumnSchemaInterface + public function uuidPrimaryKey(): ColumnInterface { return ColumnBuilder::uuidPrimaryKey(); } @@ -89,11 +89,11 @@ public function uuidPrimaryKey(): ColumnSchemaInterface * * This parameter will be ignored if not supported by the DBMS. * - * @return ColumnSchemaInterface The column instance which can be further customized. + * @return ColumnInterface The column instance which can be further customized. * * @deprecated Use {@see ColumnBuilder::uuidPrimaryKey()} instead. Will be removed in 2.0.0. */ - public function uuidPrimaryKeySequenced(): ColumnSchemaInterface + public function uuidPrimaryKeySequenced(): ColumnInterface { return ColumnBuilder::uuidPrimaryKey(); } @@ -103,11 +103,11 @@ public function uuidPrimaryKeySequenced(): ColumnSchemaInterface * * This parameter will be ignored if not supported by the DBMS. * - * @return ColumnSchemaInterface The column instance which can be further customized. + * @return ColumnInterface The column instance which can be further customized. * * @deprecated Use {@see ColumnBuilder::uuid()} instead. Will be removed in 2.0.0. */ - public function uuid(): ColumnSchemaInterface + public function uuid(): ColumnInterface { return ColumnBuilder::uuid(); } @@ -119,11 +119,11 @@ public function uuid(): ColumnSchemaInterface * * This parameter will be ignored if not supported by the DBMS. * - * @return ColumnSchemaInterface The column instance which can be further customized. + * @return ColumnInterface The column instance which can be further customized. * * @deprecated Use {@see ColumnBuilder::binary()} instead. Will be removed in 2.0.0. */ - public function binary(int $length = null): ColumnSchemaInterface + public function binary(int $length = null): ColumnInterface { return ColumnBuilder::binary($length); } @@ -131,11 +131,11 @@ public function binary(int $length = null): ColumnSchemaInterface /** * Creates a boolean column. * - * @return ColumnSchemaInterface The column instance which can be further customized. + * @return ColumnInterface The column instance which can be further customized. * * @deprecated Use {@see ColumnBuilder::boolean()} instead. Will be removed in 2.0.0. */ - public function boolean(): ColumnSchemaInterface + public function boolean(): ColumnInterface { return ColumnBuilder::boolean(); } @@ -147,11 +147,11 @@ public function boolean(): ColumnSchemaInterface * * This parameter will be ignored if not supported by the DBMS. * - * @return ColumnSchemaInterface The column instance which can be further customized. + * @return ColumnInterface The column instance which can be further customized. * * @deprecated Use {@see ColumnBuilder::char()} instead. Will be removed in 2.0.0. */ - public function char(int $length = null): ColumnSchemaInterface + public function char(int $length = null): ColumnInterface { return ColumnBuilder::char($length); } @@ -159,11 +159,11 @@ public function char(int $length = null): ColumnSchemaInterface /** * Creates a date column. * - * @return ColumnSchemaInterface The column instance which can be further customized. + * @return ColumnInterface The column instance which can be further customized. * * @deprecated Use {@see ColumnBuilder::date()} instead. Will be removed in 2.0.0. */ - public function date(): ColumnSchemaInterface + public function date(): ColumnInterface { return ColumnBuilder::date(); } @@ -176,11 +176,11 @@ public function date(): ColumnSchemaInterface * * This parameter will be ignored if not supported by the DBMS. * - * @return ColumnSchemaInterface The column instance which can be further customized. + * @return ColumnInterface The column instance which can be further customized. * * @deprecated Use {@see ColumnBuilder::datetime()} instead. Will be removed in 2.0.0. */ - public function dateTime(int $precision = null): ColumnSchemaInterface + public function dateTime(int $precision = null): ColumnInterface { return ColumnBuilder::datetime($precision); } @@ -197,11 +197,11 @@ public function dateTime(int $precision = null): ColumnSchemaInterface * * This parameter will be ignored if not supported by the DBMS. * - * @return ColumnSchemaInterface The column instance which can be further customized. + * @return ColumnInterface The column instance which can be further customized. * * @deprecated Use {@see ColumnBuilder::decimal()} instead. Will be removed in 2.0.0. */ - public function decimal(int $precision = null, int $scale = null): ColumnSchemaInterface + public function decimal(int $precision = null, int $scale = null): ColumnInterface { return ColumnBuilder::decimal($precision, $scale); } @@ -214,11 +214,11 @@ public function decimal(int $precision = null, int $scale = null): ColumnSchemaI * * This parameter will be ignored if not supported by the DBMS. * - * @return ColumnSchemaInterface The column instance which can be further customized. + * @return ColumnInterface The column instance which can be further customized. * * @deprecated Use {@see ColumnBuilder::double()} instead. Will be removed in 2.0.0. */ - public function double(int $precision = null): ColumnSchemaInterface + public function double(int $precision = null): ColumnInterface { return ColumnBuilder::double($precision); } @@ -231,11 +231,11 @@ public function double(int $precision = null): ColumnSchemaInterface * * This parameter will be ignored if not supported by the DBMS. * - * @return ColumnSchemaInterface The column instance which can be further customized. + * @return ColumnInterface The column instance which can be further customized. * * @deprecated Use {@see ColumnBuilder::float()} instead. Will be removed in 2.0.0. */ - public function float(int $precision = null): ColumnSchemaInterface + public function float(int $precision = null): ColumnInterface { return ColumnBuilder::float($precision); } @@ -247,11 +247,11 @@ public function float(int $precision = null): ColumnSchemaInterface * * This parameter will be ignored if not supported by the DBMS. * - * @return ColumnSchemaInterface The column instance which can be further customized. + * @return ColumnInterface The column instance which can be further customized. * * @deprecated Use {@see ColumnBuilder::integer()} instead. Will be removed in 2.0.0. */ - public function integer(int $length = null): ColumnSchemaInterface + public function integer(int $length = null): ColumnInterface { return ColumnBuilder::integer($length); } @@ -259,11 +259,11 @@ public function integer(int $length = null): ColumnSchemaInterface /** * Creates a JSON column. * - * @return ColumnSchemaInterface The column instance which can be further customized. + * @return ColumnInterface The column instance which can be further customized. * * @deprecated Use {@see ColumnBuilder::json()} instead. Will be removed in 2.0.0. */ - public function json(): ColumnSchemaInterface + public function json(): ColumnInterface { return ColumnBuilder::json(); } @@ -280,11 +280,11 @@ public function json(): ColumnSchemaInterface * * This parameter will be ignored if not supported by the DBMS. * - * @return ColumnSchemaInterface The column instance which can be further customized. + * @return ColumnInterface The column instance which can be further customized. * * @deprecated Use {@see ColumnBuilder::money()} instead. Will be removed in 2.0.0. */ - public function money(int $precision = null, int $scale = null): ColumnSchemaInterface + public function money(int $precision = null, int $scale = null): ColumnInterface { return ColumnBuilder::money($precision, $scale); } @@ -296,11 +296,11 @@ public function money(int $precision = null, int $scale = null): ColumnSchemaInt * * This parameter will be ignored if not supported by the DBMS. * - * @return ColumnSchemaInterface The column instance which can be further customized. + * @return ColumnInterface The column instance which can be further customized. * * @deprecated Use {@see ColumnBuilder::primaryKey()} instead. Will be removed in 2.0.0. */ - public function primaryKey(int $length = null): ColumnSchemaInterface + public function primaryKey(int $length = null): ColumnInterface { return ColumnBuilder::primaryKey()->size($length); } @@ -312,11 +312,11 @@ public function primaryKey(int $length = null): ColumnSchemaInterface * * This parameter will be ignored if not supported by the DBMS. * - * @return ColumnSchemaInterface The column instance which can be further customized. + * @return ColumnInterface The column instance which can be further customized. * * @deprecated Use {@see ColumnBuilder::smallint()} instead. Will be removed in 2.0.0. */ - public function smallInteger(int $length = null): ColumnSchemaInterface + public function smallInteger(int $length = null): ColumnInterface { return ColumnBuilder::smallint($length); } @@ -328,11 +328,11 @@ public function smallInteger(int $length = null): ColumnSchemaInterface * * This parameter will be ignored if not supported by the DBMS. * - * @return ColumnSchemaInterface The column instance which can be further customized. + * @return ColumnInterface The column instance which can be further customized. * * @deprecated Use {@see ColumnBuilder::string()} instead. Will be removed in 2.0.0. */ - public function string(int $length = null): ColumnSchemaInterface + public function string(int $length = null): ColumnInterface { return ColumnBuilder::string($length); } @@ -340,11 +340,11 @@ public function string(int $length = null): ColumnSchemaInterface /** * Creates a text column. * - * @return ColumnSchemaInterface The column instance which can be further customized. + * @return ColumnInterface The column instance which can be further customized. * * @deprecated Use {@see ColumnBuilder::text()} instead. Will be removed in 2.0.0. */ - public function text(): ColumnSchemaInterface + public function text(): ColumnInterface { return ColumnBuilder::text(); } @@ -357,11 +357,11 @@ public function text(): ColumnSchemaInterface * * This parameter will be ignored if not supported by the DBMS. * - * @return ColumnSchemaInterface The column instance which can be further customized. + * @return ColumnInterface The column instance which can be further customized. * * @deprecated Use {@see ColumnBuilder::time()} instead. Will be removed in 2.0.0. */ - public function time(int $precision = null): ColumnSchemaInterface + public function time(int $precision = null): ColumnInterface { return ColumnBuilder::time($precision); } @@ -374,11 +374,11 @@ public function time(int $precision = null): ColumnSchemaInterface * * This parameter will be ignored if not supported by the DBMS. * - * @return ColumnSchemaInterface The column instance which can be further customized. + * @return ColumnInterface The column instance which can be further customized. * * @deprecated Use {@see ColumnBuilder::timestamp()} instead. Will be removed in 2.0.0. */ - public function timestamp(int $precision = null): ColumnSchemaInterface + public function timestamp(int $precision = null): ColumnInterface { return ColumnBuilder::timestamp($precision); } @@ -390,11 +390,11 @@ public function timestamp(int $precision = null): ColumnSchemaInterface * * This parameter will be ignored if not supported by the DBMS. * - * @return ColumnSchemaInterface The column instance which can be further customized. + * @return ColumnInterface The column instance which can be further customized. * * @deprecated Use {@see ColumnBuilder::tinyint()} instead. Will be removed in 2.0.0. */ - public function tinyInteger(int $length = null): ColumnSchemaInterface + public function tinyInteger(int $length = null): ColumnInterface { return ColumnBuilder::tinyint($length); } diff --git a/src/MigrationBuilder.php b/src/MigrationBuilder.php index 274bd003..048aac00 100644 --- a/src/MigrationBuilder.php +++ b/src/MigrationBuilder.php @@ -15,7 +15,7 @@ use Yiisoft\Db\QueryBuilder\QueryBuilderInterface; use Yiisoft\Db\Migration\Informer\MigrationInformerInterface; use Yiisoft\Db\Schema\Column\ColumnBuilder; -use Yiisoft\Db\Schema\Column\ColumnSchemaInterface; +use Yiisoft\Db\Schema\Column\ColumnInterface; use function implode; use function ltrim; @@ -187,14 +187,14 @@ public function delete(string $table, array|string $condition = '', array $param * The columns in the new table should be specified as name-definition pairs (e.g. 'name' => 'string'), where name * is the name of the column which will be properly quoted by the method, and definition is the type of the column * which can contain a native database column type, {@see ColumnType abstract} or {@see PseudoType pseudo} type, - * or can be represented as instance of {@see ColumnSchemaInterface}. + * or can be represented as instance of {@see ColumnInterface}. * * The {@see QueryBuilderInterface::buildColumnDefinition()} method will be invoked to convert column definitions * into SQL representation. For example, it will convert `string not null` to `varchar(255) not null` * and `pk` to `int PRIMARY KEY AUTO_INCREMENT` (for MySQL). * * The preferred way is to use {@see ColumnBuilder} to generate column definitions as instances of - * {@see ColumnSchemaInterface}. + * {@see ColumnInterface}. * * ```php * $this->createTable( @@ -216,14 +216,14 @@ public function delete(string $table, array|string $condition = '', array $param * generated SQL. * * @param string $table The name of the table to be created. The name will be properly quoted by the method. - * @param (ColumnSchemaInterface|string)[] $columns The columns (name => definition) in the new table. + * @param (ColumnInterface|string)[] $columns The columns (name => definition) in the new table. * @param string|null $options Additional SQL fragment that will be appended to the generated SQL. * * @throws Exception * @throws InvalidConfigException * @throws NotSupportedException * - * @psalm-param array $columns + * @psalm-param array $columns */ public function createTable(string $table, array $columns, string|null $options = null): void { @@ -232,7 +232,7 @@ public function createTable(string $table, array $columns, string|null $options $this->db->createCommand()->createTable($table, $columns, $options)->execute(); foreach ($columns as $column => $type) { - if ($type instanceof ColumnSchemaInterface) { + if ($type instanceof ColumnInterface) { $comment = $type->getComment(); if ($comment !== null) { $this->db->createCommand()->addCommentOnColumn($table, $column, $comment)->execute(); @@ -290,18 +290,18 @@ public function truncateTable(string $table): void * @param string $table The table that the new column will be added to. * The table name will be properly quoted by the method. * @param string $column The name of the new column. The name will be properly quoted by the method. - * @param ColumnSchemaInterface|string $type The column type which can contain a native database column type, + * @param ColumnInterface|string $type The column type which can contain a native database column type, * {@see ColumnType abstract} or {@see PseudoType pseudo} type, or can be represented as instance of - * {@see ColumnSchemaInterface}. + * {@see ColumnInterface}. * * The {@see QueryBuilderInterface::buildColumnDefinition()} method will be invoked to convert column definitions * into SQL representation. For example, it will convert `string not null` to `varchar(255) not null` * and `pk` to `int PRIMARY KEY AUTO_INCREMENT` (for MySQL). * * The preferred way is to use {@see ColumnBuilder} to generate column definitions as instances of - * {@see ColumnSchemaInterface}. + * {@see ColumnInterface}. */ - public function addColumn(string $table, string $column, ColumnSchemaInterface|string $type): void + public function addColumn(string $table, string $column, ColumnInterface|string $type): void { if (is_string($type)) { $comment = null; @@ -357,22 +357,22 @@ public function renameColumn(string $table, string $name, string $newName): void * * @param string $table The table whose column is to be changed. The method will properly quote the table name. * @param string $column The name of the column to be changed. The name will be properly quoted by the method. - * @param ColumnSchemaInterface|string $type The column type which can contain a native database column type, + * @param ColumnInterface|string $type The column type which can contain a native database column type, * {@see ColumnType abstract} or {@see PseudoType pseudo} type, or can be represented as instance of - * {@see ColumnSchemaInterface}. + * {@see ColumnInterface}. * * The {@see QueryBuilderInterface::buildColumnDefinition()} method will be invoked to convert column definitions * into SQL representation. For example, it will convert `string not null` to `varchar(255) not null` * and `pk` to `int PRIMARY KEY AUTO_INCREMENT` (for MySQL). * * The preferred way is to use {@see ColumnBuilder} to generate column definitions as instances of - * {@see ColumnSchemaInterface}. + * {@see ColumnInterface}. * * @throws Exception * @throws InvalidConfigException * @throws NotSupportedException */ - public function alterColumn(string $table, string $column, ColumnSchemaInterface|string $type): void + public function alterColumn(string $table, string $column, ColumnInterface|string $type): void { if (is_string($type)) { $comment = null;