Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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, #283: Adapt to Yii DB changes (@Tigrov)
- Enh #282, #283, #293: Adapt to Yii DB changes (@Tigrov)
- Bug #286: Explicitly mark nullable parameters (@vjik)
- Chg #287: Change supported PHP versions to `8.1 - 8.4` (@Tigrov)
- Enh #287: Minor refactoring (@Tigrov)
Expand Down
6 changes: 1 addition & 5 deletions src/MigrationBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Yiisoft\Db\Constant\IndexType;
use Yiisoft\Db\Constant\PseudoType;
use Yiisoft\Db\Constant\ReferentialAction;
use Yiisoft\Db\Constraint\Constraint;
use Yiisoft\Db\Exception\InvalidConfigException;
use Yiisoft\Db\Exception\NotSupportedException;
use Yiisoft\Db\Query\QueryInterface;
Expand Down Expand Up @@ -123,7 +122,6 @@
* @param array|bool $updateColumns The column data (name => value) to be updated if they already exist.
* If `true` is passed, the column data will be updated to match the insert column data.
* If `false` is passed, no update will be performed if the column data already exists.
* @param array $params The parameters to be bound to the command.
*
* @psalm-param array<string, mixed>|QueryInterface $insertColumns
*
Expand All @@ -135,10 +133,9 @@
string $table,
array|QueryInterface $insertColumns,
array|bool $updateColumns = true,
array $params = []
): void {
$time = $this->beginCommand("Upsert into $table");
$this->db->createCommand()->upsert($table, $insertColumns, $updateColumns, $params)->execute();
$this->db->createCommand()->upsert($table, $insertColumns, $updateColumns)->execute();

Check warning on line 138 in src/MigrationBuilder.php

View check run for this annotation

Codecov / codecov/patch

src/MigrationBuilder.php#L138

Added line #L138 was not covered by tests
$this->endCommand($time);
}

Expand Down Expand Up @@ -689,7 +686,6 @@

private function hasIndex(string $table, string $column): bool
{
/** @var Constraint[] $indexes */
$indexes = $this->db->getSchema()->getTableIndexes($table);

foreach ($indexes as $index) {
Expand Down
4 changes: 2 additions & 2 deletions src/Service/Generate/ForeignKeyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
$tablePrimaryKeys = $this->db->getSchema()->getTablePrimaryKey($relatedTable);

if ($tablePrimaryKeys !== null) {
$primaryKeys = (array) $tablePrimaryKeys->getColumnNames();
$primaryKeys = $tablePrimaryKeys->getColumnNames();

Check warning on line 40 in src/Service/Generate/ForeignKeyFactory.php

View check run for this annotation

Codecov / codecov/patch

src/Service/Generate/ForeignKeyFactory.php#L40

Added line #L40 was not covered by tests

match (count($primaryKeys)) {
1 => $relatedColumn = (string) $primaryKeys[0],
1 => $relatedColumn = $primaryKeys[0],

Check warning on line 43 in src/Service/Generate/ForeignKeyFactory.php

View check run for this annotation

Codecov / codecov/patch

src/Service/Generate/ForeignKeyFactory.php#L43

Added line #L43 was not covered by tests
default => $this->io?->writeln(
"<fg=yellow> Related table for field \"$column\" exists, but primary key is composite. Default name \"id\" will be used for related field</>\n"
),
Expand Down
2 changes: 1 addition & 1 deletion tests/Common/AbstractMigrationBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ public function testCreateIndex(): void
$this->assertSame('unique_index', $index->getName());
$this->assertSame(['id'], $index->getColumnNames());
$this->assertTrue($index->isUnique());
$this->assertFalse($index->isPrimary());
$this->assertFalse($index->isPrimaryKey());
$this->assertInformerOutputContains(
' > Create UNIQUE index unique_index on test_table (id) ... Done in ',
);
Expand Down
2 changes: 1 addition & 1 deletion tests/Driver/Mysql/MigrationBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function testCreateIndexWithMethod(): void
$this->assertSame('unique_index', $index->getName());
$this->assertSame(['id'], $index->getColumnNames());
$this->assertTrue($index->isUnique());
$this->assertFalse($index->isPrimary());
$this->assertFalse($index->isPrimaryKey());
$this->assertInformerOutputContains(
' > Create UNIQUE index unique_index on test_table (id) using BTREE ... Done in ',
);
Expand Down
Loading