Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2288 - Add name and version to pending actions error and apply 2272 to 0.13.x #2290

Closed
wants to merge 4 commits into from
Closed
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
20 changes: 10 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,29 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: ['7.2', '7.4', '8.0', '8.1', '8.2']
php-version: ['7.4', '8.0', '8.1', '8.2']
db-type: [sqlite, mysql, pgsql]
prefer-lowest: ['']
include:
- php-version: '7.2'
- php-version: '7.4'
db-type: mysql
prefer-lowest: prefer-lowest

steps:
- name: Setup MySQL latest
if: matrix.db-type == 'mysql' && matrix.php-version != '7.2'
run: docker run --rm --name=mysqld -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=cakephp -p 3306:3306 -d mysql --default-authentication-plugin=mysql_native_password
if: matrix.db-type == 'mysql' && matrix.php-version != '7.4'
run: docker run --rm --name=mysqld -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=cakephp -p 3306:3306 -d mysql:8.3 --default-authentication-plugin=mysql_native_password

- name: Setup MySQL 5.6
if: matrix.db-type == 'mysql' && matrix.php-version == '7.2'
if: matrix.db-type == 'mysql' && matrix.php-version == '7.4'
run: docker run --rm --name=mysqld -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=cakephp -p 3306:3306 -d mysql:5.6 --character-set-server=utf8

- name: Setup PostgreSQL latest
if: matrix.db-type == 'pgsql' && matrix.php-version != '7.2'
if: matrix.db-type == 'pgsql' && matrix.php-version != '7.4'
run: docker run --rm --name=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=cakephp -p 5432:5432 -d postgres

- name: Setup PostgreSQL 9.4
if: matrix.db-type == 'pgsql' && matrix.php-version == '7.2'
if: matrix.db-type == 'pgsql' && matrix.php-version == '7.4'
run: docker run --rm --name=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=cakephp -p 5432:5432 -d postgres:9.4

- uses: actions/checkout@v3
Expand Down Expand Up @@ -70,7 +70,7 @@ jobs:
fi

- name: Setup problem matchers for PHPUnit
if: matrix.php-version == '7.2' && matrix.db-type == 'mysql'
if: matrix.php-version == '7.4' && matrix.db-type == 'mysql'
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Setup Database
Expand Down Expand Up @@ -109,11 +109,11 @@ jobs:

testsuite-windows:
runs-on: windows-2019
name: Windows - PHP 7.2 & SQL Server
name: Windows - PHP 7.4 & SQL Server

env:
EXTENSIONS: pdo_sqlsrv
PHP_VERSION: '7.2'
PHP_VERSION: '7.4'

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
}
],
"require": {
"php": ">=7.2",
"php": ">=7.4.0",
"cakephp/database": "^4.0",
"psr/container": "^1.0 || ^2.0",
"symfony/console": "^3.4|^4.0|^5.0|^6.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Phinx/Migration/AbstractMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public function postFlightCheck(): void
{
foreach ($this->tables as $table) {
if ($table->hasPendingActions()) {
throw new RuntimeException('Migration has pending actions after execution!');
throw new RuntimeException(sprintf('Migration %s_%s has pending actions after execution!', $this->getVersion(), $this->getName()));
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/Phinx/Migration/Manager/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,17 @@ public function executeMigration(MigrationInterface $migration, string $directio
} else {
$migration->{$direction}();
}

// commit the transaction if the adapter supports it
if ($this->getAdapter()->hasTransactions()) {
$this->getAdapter()->commitTransaction();
}
}

$migration->postFlightCheck();

// Record it in the database
$this->getAdapter()->migrated($migration, $direction, date('Y-m-d H:i:s', $startTime), date('Y-m-d H:i:s', time()));

$migration->postFlightCheck();

// commit the transaction if the adapter supports it
if ($this->getAdapter()->hasTransactions()) {
$this->getAdapter()->commitTransaction();
}
}

/**
Expand Down
5 changes: 5 additions & 0 deletions tests/Phinx/Db/Adapter/MysqlAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2070,6 +2070,11 @@ public function testQueryBuilder()
->addColumn('int_col', 'integer')
->save();

if (method_exists(\Cake\Database\Connection::class, 'selectQuery')) {
$this->expectDeprecation();
$this->expectExceptionMessage('As of 4.5.0, using newQuery() is deprecated. Instead, use `insertQuery()`, `deleteQuery()`, `selectQuery()` or `updateQuery()`. The query objects returned by these methods will emit deprecations that will become fatal errors in 5.0.See https://book.cakephp.org/4/en/appendices/4-5-migration-guide.html for more information');
}

$builder = $this->adapter->getQueryBuilder();
$stm = $builder
->insert(['string_col', 'int_col'])
Expand Down
5 changes: 5 additions & 0 deletions tests/Phinx/Db/Adapter/PostgresAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2415,6 +2415,11 @@ public function testQueryBuilder()
->addColumn('int_col', 'integer')
->save();

if (method_exists(\Cake\Database\Connection::class, 'selectQuery')) {
$this->expectDeprecation();
$this->expectExceptionMessage('As of 4.5.0, using newQuery() is deprecated. Instead, use `insertQuery()`, `deleteQuery()`, `selectQuery()` or `updateQuery()`. The query objects returned by these methods will emit deprecations that will become fatal errors in 5.0.See https://book.cakephp.org/4/en/appendices/4-5-migration-guide.html for more information');
}

$builder = $this->adapter->getQueryBuilder();
$stm = $builder
->insert(['string_col', 'int_col'])
Expand Down
5 changes: 5 additions & 0 deletions tests/Phinx/Db/Adapter/SQLiteAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1274,6 +1274,11 @@ public function testQueryBuilder()
->addColumn('int_col', 'integer')
->save();

if (method_exists(\Cake\Database\Connection::class, 'selectQuery')) {
$this->expectDeprecation();
$this->expectExceptionMessage('As of 4.5.0, using newQuery() is deprecated. Instead, use `insertQuery()`, `deleteQuery()`, `selectQuery()` or `updateQuery()`. The query objects returned by these methods will emit deprecations that will become fatal errors in 5.0.See https://book.cakephp.org/4/en/appendices/4-5-migration-guide.html for more information');
}

$builder = $this->adapter->getQueryBuilder();
$stm = $builder
->insert(['string_col', 'int_col'])
Expand Down
5 changes: 5 additions & 0 deletions tests/Phinx/Db/Adapter/SqlServerAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,11 @@ public function testQueryBuilder()
->addColumn('int_col', 'integer')
->save();

if (method_exists(\Cake\Database\Connection::class, 'selectQuery')) {
$this->expectDeprecation();
$this->expectExceptionMessage('As of 4.5.0, using newQuery() is deprecated. Instead, use `insertQuery()`, `deleteQuery()`, `selectQuery()` or `updateQuery()`. The query objects returned by these methods will emit deprecations that will become fatal errors in 5.0.See https://book.cakephp.org/4/en/appendices/4-5-migration-guide.html for more information');
}

$builder = $this->adapter->getQueryBuilder();
$stm = $builder
->insert(['string_col', 'int_col'])
Expand Down
4 changes: 2 additions & 2 deletions tests/Phinx/Migration/AbstractMigrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public function testTableMethod()
public function testPostFlightCheckFail()
{
// stub migration
$migrationStub = $this->getMockForAbstractClass('\Phinx\Migration\AbstractMigration', ['mockenv', 0]);
$migrationStub = $this->getMockForAbstractClass('\Phinx\Migration\AbstractMigration', ['mockenv', 20230102030405], 'PostFlightCheck');

$adapterStub = $this->getMockBuilder('\Phinx\Db\Adapter\MysqlAdapter')
->setConstructorArgs([[]])
Expand All @@ -277,7 +277,7 @@ public function testPostFlightCheckFail()
$table->addColumn('column1', 'integer', ['null' => true]);

$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage('Migration has pending actions after execution!');
$this->expectExceptionMessage('Migration 20230102030405_PostFlightCheck has pending actions after execution!');

$migrationStub->postFlightCheck();
}
Expand Down
Loading