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
4 changes: 2 additions & 2 deletions src/Migration/AbstractPdoMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ abstract protected function doDown(): void;
* Add SQL
*
* @param string $sql
* @param array<string|int, int|float|string> $parameters
* @param array<string|int, int|float|string|null> $parameters
*/
final protected function addSql(string $sql, array $parameters = []): void
{
Expand All @@ -63,7 +63,7 @@ final protected function addSql(string $sql, array $parameters = []): void
/**
* Execute SQL entry.
*
* @param array{"0": string, "1": array<string|int, string|int|float>, "2": string} $entry
* @param array{"0": string, "1": array<string|int, string|int|float|null>, "2": string} $entry
*
* @throws MigrationFailedException
*/
Expand Down
5 changes: 3 additions & 2 deletions tests/Functional/Console/ExecuteMigrationCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ public function shouldSuccessExecuteDown(): void
$rows = $this->executeSql('SELECT * FROM test_1 ORDER BY id ASC');

self::assertEquals([
['id' => 1, 'label' => 'Bla Bla'],
['id' => 2, 'label' => 'Foo Bar'],
['id' => 1, 'label' => 'Bla Bla', 'description' => null],
['id' => 2, 'label' => 'Foo Bar', 'description' => 'some description'],
['id' => 3, 'label' => 'Bar Bar', 'description' => null],
], $rows);
}
}
15 changes: 9 additions & 6 deletions tests/Functional/Console/MigrateCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ public function shouldSuccessUp(): void
$rows = $this->executeSql('SELECT * FROM test_1 ORDER BY id ASC');

self::assertEquals([
['id' => 1, 'label' => 'Bla Bla', 'active' => 1],
['id' => 2, 'label' => 'Foo Bar', 'active' => 1],
['id' => 1, 'label' => 'Bla Bla', 'active' => 1, 'description' => null],
['id' => 2, 'label' => 'Foo Bar', 'active' => 1, 'description' => 'some description'],
['id' => 3, 'label' => 'Bar Bar', 'active' => 1, 'description' => null],
], $rows);
}

Expand All @@ -80,8 +81,9 @@ public function shouldSuccessUpToSpecificVersion(): void
$rows = $this->executeSql('SELECT * FROM test_1 ORDER BY id ASC');

self::assertEquals([
['id' => 1, 'label' => 'Bla Bla'],
['id' => 2, 'label' => 'Foo Bar'],
['id' => 1, 'label' => 'Bla Bla', 'description' => null],
['id' => 2, 'label' => 'Foo Bar', 'description' => 'some description'],
['id' => 3, 'label' => 'Bar Bar', 'description' => null],
], $rows);
}

Expand Down Expand Up @@ -127,8 +129,9 @@ public function shouldSuccessDownToSpecificVersion(): void
$rows = $this->executeSql('SELECT * FROM test_1 ORDER BY id ASC');

self::assertEquals([
['id' => 1, 'label' => 'Bla Bla'],
['id' => 2, 'label' => 'Foo Bar'],
['id' => 1, 'label' => 'Bla Bla', 'description' => null],
['id' => 2, 'label' => 'Foo Bar', 'description' => 'some description'],
['id' => 3, 'label' => 'Bar Bar', 'description' => null],
], $rows);
}

Expand Down
25 changes: 15 additions & 10 deletions tests/Functional/Migrator/MigratorMySqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ public function shouldSuccessUp(): void
$rows = $this->executeSql('SELECT * FROM test_1 ORDER BY id ASC');

self::assertEquals([
['id' => 1, 'label' => 'Bla Bla', 'active' => 1],
['id' => 2, 'label' => 'Foo Bar', 'active' => 1],
['id' => 1, 'label' => 'Bla Bla', 'active' => 1, 'description' => null],
['id' => 2, 'label' => 'Foo Bar', 'active' => 1, 'description' => 'some description'],
['id' => 3, 'label' => 'Bar Bar', 'active' => 1, 'description' => null],
], $rows);
}

Expand All @@ -83,8 +84,9 @@ public function shouldSuccessUpToSpecificVersion(): void
$rows = $this->executeSql('SELECT * FROM test_1 ORDER BY id ASC');

self::assertEquals([
['id' => 1, 'label' => 'Bla Bla'],
['id' => 2, 'label' => 'Foo Bar'],
['id' => 1, 'label' => 'Bla Bla', 'description' => null],
['id' => 2, 'label' => 'Foo Bar', 'description' => 'some description'],
['id' => 3, 'label' => 'Bar Bar', 'description' => null],
], $rows);
}

Expand All @@ -98,8 +100,9 @@ public function shouldSuccessDownToSpecificVersion(): void
$rows = $this->executeSql('SELECT * FROM test_1 ORDER BY id ASC');

self::assertEquals([
['id' => 1, 'label' => 'Bla Bla'],
['id' => 2, 'label' => 'Foo Bar'],
['id' => 1, 'label' => 'Bla Bla', 'description' => null],
['id' => 2, 'label' => 'Foo Bar', 'description' => 'some description'],
['id' => 3, 'label' => 'Bar Bar', 'description' => null],
], $rows);
}

Expand All @@ -113,17 +116,19 @@ public function shouldSuccessExecuteSpecificVersion(): void
$rows = $this->executeSql('SELECT * FROM test_1 ORDER BY id ASC');

self::assertEquals([
['id' => 1, 'label' => 'Bla Bla', 'active' => 1],
['id' => 2, 'label' => 'Foo Bar', 'active' => 1],
['id' => 1, 'label' => 'Bla Bla', 'active' => 1, 'description' => null],
['id' => 2, 'label' => 'Foo Bar', 'active' => 1, 'description' => 'some description'],
['id' => 3, 'label' => 'Bar Bar', 'active' => 1, 'description' => null],
], $rows);

$this->migrator->execute(MigrateDirection::Down, '03');

$rows = $this->executeSql('SELECT * FROM test_1 ORDER BY id ASC');

self::assertEquals([
['id' => 1, 'label' => 'Bla Bla'],
['id' => 2, 'label' => 'Foo Bar'],
['id' => 1, 'label' => 'Bla Bla', 'description' => null],
['id' => 2, 'label' => 'Foo Bar', 'description' => 'some description'],
['id' => 3, 'label' => 'Bar Bar', 'description' => null],
], $rows);
}

Expand Down
3 changes: 2 additions & 1 deletion tests/Migrations/DataSet02/Version01.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ protected function doUp(): void
{
$this->addSql('CREATE TABLE test_1 (
id INT AUTO_INCREMENT NOT NULL PRIMARY KEY,
label VARCHAR(255) NOT NULL
label VARCHAR(255) NOT NULL,
description VARCHAR(255) DEFAULT NULL
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
}

Expand Down
3 changes: 2 additions & 1 deletion tests/Migrations/DataSet02/Version02.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public function getDescription(): string
protected function doUp(): void
{
$this->addSql('INSERT INTO test_1 (id, label) VALUES (?, ?)', [1, 'Bla Bla']);
$this->addSql('INSERT INTO test_1 (id, label) VALUES (:id, :label)', ['id' => 2, 'label' => 'Foo Bar']);
$this->addSql('INSERT INTO test_1 (id, label, description) VALUES (:id, :label, :description)', ['id' => 2, 'label' => 'Foo Bar', 'description' => 'some description']);
$this->addSql('INSERT INTO test_1 (id, label, description) VALUES (:id, :label, :description)', ['id' => 3, 'label' => 'Bar Bar', 'description' => null]);
}

protected function doDown(): void
Expand Down
Loading