From 9598d586c392d7403a35cfbd1a96d59daaef42f7 Mon Sep 17 00:00:00 2001 From: Tigrov Date: Thu, 9 May 2024 14:31:33 +0700 Subject: [PATCH 1/2] Remove `TableSchemaInterface::compositeForeignKey()` method [skip ci] --- CHANGELOG.md | 1 + UPGRADE.md | 1 + src/Schema/AbstractTableSchema.php | 5 ----- src/Schema/TableSchemaInterface.php | 13 ------------- tests/AbstractTableSchemaTest.php | 10 ---------- 5 files changed, 2 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81ce4717f..dd7283b12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ - Chg #837: Remove `$table` parameter from `normalizeColumnNames()` and `getNormalizeColumnNames()` methods of `AbstractDMLQueryBuilder` class (@Tigrov) - Chg #838: Remove `SchemaInterface::TYPE_JSONB` constant (@Tigrov) +- Chg #839: Remove `TableSchemaInterface::compositeForeignKey()` method (@Tigrov) ## 1.3.0 March 21, 2024 diff --git a/UPGRADE.md b/UPGRADE.md index 19f330517..6af704b1f 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -62,6 +62,7 @@ $db->createCommand()->insertBatch('user', $values)->execute(); ### Remove deprecated methods - `AbstractDMLQueryBuilder::getTypecastValue()` +- `TableSchemaInterface::compositeForeignKey()` ### Remove deprecated parameters diff --git a/src/Schema/AbstractTableSchema.php b/src/Schema/AbstractTableSchema.php index e5b6ada95..1e25f5df6 100644 --- a/src/Schema/AbstractTableSchema.php +++ b/src/Schema/AbstractTableSchema.php @@ -152,9 +152,4 @@ public function foreignKey(string|int $id, array $to): void { $this->foreignKeys[$id] = $to; } - - public function compositeForeignKey(int $id, string $from, string $to): void - { - throw new NotSupportedException(static::class . ' does not support composite FK.'); - } } diff --git a/src/Schema/TableSchemaInterface.php b/src/Schema/TableSchemaInterface.php index 47fe0c107..4452328b3 100644 --- a/src/Schema/TableSchemaInterface.php +++ b/src/Schema/TableSchemaInterface.php @@ -201,17 +201,4 @@ public function foreignKeys(array $value): void; * @param array $to The foreign key. */ public function foreignKey(string|int $id, array $to): void; - - /** - * Set composite foreign key. - * - * @param int $id The index of foreign key. - * @param string $from The column name in current table. - * @param string $to The column name in foreign table. - * - * @throws NotSupportedException - * - * @deprecated will be removed in version 2.0.0 - */ - public function compositeForeignKey(int $id, string $from, string $to): void; } diff --git a/tests/AbstractTableSchemaTest.php b/tests/AbstractTableSchemaTest.php index a22446710..e10a6cecf 100644 --- a/tests/AbstractTableSchemaTest.php +++ b/tests/AbstractTableSchemaTest.php @@ -14,16 +14,6 @@ abstract class AbstractTableSchemaTest extends TestCase { use TestTrait; - public function testCompositeFk(): void - { - $tableSchema = new TableSchema(); - - $this->expectException(NotSupportedException::class); - $this->expectExceptionMessage('Yiisoft\Db\Tests\Support\Stub\TableSchema does not support composite FK.'); - - $tableSchema->compositeForeignKey(1, 'from', 'to'); - } - public function testGetCatalogName(): void { $tableSchema = new TableSchema(); From a302e5b053fac32c4f44d59b2729286688efb4c1 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Thu, 9 May 2024 07:31:54 +0000 Subject: [PATCH 2/2] Apply fixes from StyleCI --- src/Schema/AbstractTableSchema.php | 2 -- src/Schema/TableSchemaInterface.php | 2 -- tests/AbstractTableSchemaTest.php | 1 - 3 files changed, 5 deletions(-) diff --git a/src/Schema/AbstractTableSchema.php b/src/Schema/AbstractTableSchema.php index 1e25f5df6..bc72ad989 100644 --- a/src/Schema/AbstractTableSchema.php +++ b/src/Schema/AbstractTableSchema.php @@ -4,8 +4,6 @@ namespace Yiisoft\Db\Schema; -use Yiisoft\Db\Exception\NotSupportedException; - use function array_keys; /** diff --git a/src/Schema/TableSchemaInterface.php b/src/Schema/TableSchemaInterface.php index 4452328b3..db1ddd1de 100644 --- a/src/Schema/TableSchemaInterface.php +++ b/src/Schema/TableSchemaInterface.php @@ -4,8 +4,6 @@ namespace Yiisoft\Db\Schema; -use Yiisoft\Db\Exception\NotSupportedException; - /** * Represents the metadata of a database table. * diff --git a/tests/AbstractTableSchemaTest.php b/tests/AbstractTableSchemaTest.php index e10a6cecf..5a4fd3ba2 100644 --- a/tests/AbstractTableSchemaTest.php +++ b/tests/AbstractTableSchemaTest.php @@ -5,7 +5,6 @@ namespace Yiisoft\Db\Tests; use PHPUnit\Framework\TestCase; -use Yiisoft\Db\Exception\NotSupportedException; use Yiisoft\Db\Tests\Support\Stub\ColumnSchema; use Yiisoft\Db\Tests\Support\Stub\TableSchema; use Yiisoft\Db\Tests\Support\TestTrait;