Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 2.0.2 under development

- New #332: Add `MigrationBuilder::insertBatch()` method, deprecate `batchInsert()` (@vjik)
- Chg #335: Remove deprecated `MigrationBuilder::batchInsert()` method (@samdark)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is BC change, the changelog line should be removed from ## 2.0.2 and added to ## 3.0.0 section before major release.

- Enh #317: Explicitly import classes, functions, and constants in "use" section (@mspirkov)
- Enh #318: Remove unnecessary files from Composer package (@mspirkov)
- Enh #319: Remove confirmation prompt from `migrate:create` command as creating a migration is non-destructive (@samdark)
Expand Down
24 changes: 0 additions & 24 deletions src/MigrationBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,30 +123,6 @@ public function insertBatch(string $table, iterable $rows, array $columns = []):
$this->endCommand($time);
}

/**
* Creates and executes a batch INSERT SQL statement.
*
* The method will properly escape the column names and bind the values to be inserted.
*
* @param string $table The table that new rows will be inserted into.
* @param string[] $columns The column names.
* @param iterable $rows The rows to be batch inserted into the table.
*
* @psalm-param iterable<iterable<array-key, mixed>> $rows
*
* @throws Exception
* @throws InvalidConfigException
* @throws NotSupportedException
*
* @deprecated Use {@see insertBatch()} instead.
*/
public function batchInsert(string $table, array $columns, iterable $rows): void
{
$time = $this->beginCommand("Insert into $table");
$this->db->createCommand()->insertBatch($table, $rows, $columns)->execute();
$this->endCommand($time);
}

/**
* Creates and executes a command to insert rows into a database table if they do not already exist (matching unique
* constraints), or update them if they do.
Expand Down
14 changes: 0 additions & 14 deletions tests/Common/AbstractMigrationBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,6 @@ public function testInsertBatchWithColumns(): void
$this->builder->dropTable('test');
}

public function testBatchInsert(): void
{
$this->builder->createTable('test', ['id' => ColumnBuilder::integer()]);
$this->builder->batchInsert('test', ['id'], [['id' => 1], ['id' => 2]]);

$this->assertEquals(
'2',
$this->db->createCommand('SELECT count(*) FROM {{test}} WHERE [[id]] IN (1, 2)')->queryScalar(),
);
$this->assertInformerOutputContains(' > Insert into test ... Done in ');

$this->builder->dropTable('test');
}

public function testUpsertWithoutRow(): void
{
$this->builder->createTable('test', ['id' => ColumnBuilder::primaryKey(), 'name' => ColumnBuilder::string()]);
Expand Down
Loading