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
25 changes: 12 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- 4.next
- 5.x
- 5.next
- 6.x
paths-ignore:
- docs/**
pull_request:
Expand All @@ -25,20 +26,20 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: ['8.2', '8.5']
php-version: ['8.4', '8.5']
db-type: [mariadb, mysql, pgsql, sqlite]
prefer-lowest: ['']
legacy-tables: ['']
include:
- php-version: '8.2'
- php-version: '8.4'
db-type: 'sqlite'
prefer-lowest: 'prefer-lowest'
- php-version: '8.3'
- php-version: '8.4'
db-type: 'mysql'
- php-version: '8.3'
- php-version: '8.4'
db-type: 'pgsql'
# Test unified cake_migrations table (non-legacy mode)
- php-version: '8.3'
- php-version: '8.4'
db-type: 'mysql'
legacy-tables: 'false'
services:
Expand Down Expand Up @@ -125,9 +126,7 @@ jobs:

- name: Composer install
run: |
if [[ ${{ matrix.php-version }} == '8.2' || ${{ matrix.php-version }} == '8.3' || ${{ matrix.php-version }} == '8.4' ]]; then
composer install
elif ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then
if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then
composer update --prefer-lowest --prefer-stable
else
composer update
Expand Down Expand Up @@ -158,23 +157,23 @@ jobs:
if [[ -n '${{ matrix.legacy-tables }}' ]]; then
export LEGACY_TABLES='${{ matrix.legacy-tables }}'
fi
if [[ ${{ matrix.php-version }} == '8.1' && ${{ matrix.db-type }} == 'mysql' ]]; then
if [[ ${{ matrix.php-version }} == '8.4' && ${{ matrix.db-type }} == 'mysql' ]]; then
vendor/bin/phpunit --coverage-clover=coverage.xml
else
vendor/bin/phpunit
fi

- name: Code Coverage Report
if: success() && matrix.php-version == '8.1' && matrix.db-type == 'mysql'
if: success() && matrix.php-version == '8.4' && matrix.db-type == 'mysql'
uses: codecov/codecov-action@v7

testsuite-windows:
runs-on: windows-2022
name: Windows - PHP 8.2 & SQL Server
name: Windows - PHP 8.4 & SQL Server

env:
EXTENSIONS: mbstring, intl, pdo_sqlsrv
PHP_VERSION: '8.2'
PHP_VERSION: '8.4'

steps:
- uses: actions/checkout@v7
Expand Down Expand Up @@ -243,5 +242,5 @@ jobs:
uses: codecov/codecov-action@v7

cs-stan:
uses: cakephp/.github/.github/workflows/cs-stan.yml@5.x
uses: cakephp/.github/.github/workflows/cs-stan.yml@6.x
secrets: inherit
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@ This is a Database Migrations system for CakePHP.

The plugin provides a complete database migration solution with support for creating, running, and managing migrations.

This branch is for use with CakePHP **5.x**. See [version map](https://github.com/cakephp/migrations/wiki#version-map) for details.
This branch is for use with CakePHP **6.x**, requiring PHP 8.4 or higher. See [version map](https://github.com/cakephp/migrations/wiki#version-map) for details.

When upgrading from CakePHP 5, regenerate schema dump files with `bin/cake migrations dump`
before baking a diff. Serialized schema metadata uses CakePHP 6's property names.

## Installation

You can install this plugin into your CakePHP application using [Composer](https://getcomposer.org).

Run the following command
```sh
composer require cakephp/migrations
composer require cakephp/migrations:"6.x-dev"
```

## Configuration
Expand Down
22 changes: 10 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@
"source": "https://github.com/cakephp/migrations"
},
"require": {
"php": ">=8.2",
"cakephp/cache": "^5.3.0",
"cakephp/database": "^5.3.2",
"cakephp/orm": "^5.3.0"
"php": ">=8.4",
"cakephp/cache": "^6.0",
"cakephp/database": "^6.0",
"cakephp/orm": "^6.0"
},
"require-dev": {
"cakephp/bake": "^3.3",
"cakephp/cakephp": "^5.3.2",
"cakephp/cakephp-codesniffer": "^5.0",
"phpunit/phpunit": "^11.5.3 || ^12.1.3 || ^13.0"
"cakephp/bake": "^4.0",
"cakephp/cakephp": "^6.0",
"cakephp/cakephp-codesniffer": "^6.0",
"phpunit/phpunit": "^12.1.3 || ^13.0"
},
"suggest": {
"cakephp/bake": "If you want to generate migrations.",
"dereuromark/cakephp-ide-helper": "If you want to have IDE suggest/autocomplete when creating migrations."
},
"minimum-stability": "stable",
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"psr-4": {
Expand All @@ -46,15 +46,13 @@
},
"autoload-dev": {
"psr-4": {
"Blog\\": "tests/test_app/Plugin/Blog/src/",
"Cake\\Test\\": "./vendor/cakephp/cakephp/tests/",
"Migrations\\Test\\": "tests/",
"Migrator\\": "tests/test_app/Plugin/Migrator/src/",
"SimpleSnapshot\\": "tests/test_app/Plugin/SimpleSnapshot/src/",
"TestApp\\": "tests/test_app/App/",
"TestBlog\\": "tests/test_app/Plugin/TestBlog/src/",
"Blog\\": "tests/test_app/Plugin/Blog/src/",
"Migrator\\": "tests/test_app/Plugin/Migrator/src/"
"Blog\\": "tests/test_app/Plugin/Blog/src/"
}
},
"config": {
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
colors="true"
cacheDirectory=".phpunit.cache"
bootstrap="tests/bootstrap.php"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.1/phpunit.xsd"
>
<testsuites>
<testsuite name="migrations">
Expand Down
3 changes: 2 additions & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
cacheDirectory: $cacheDir,
)

->withPhpSets()
// Keep language modernization separate from the CakePHP 6 API upgrade.
->withPhpSets(php82: true)
->withAttributesSets()

->withSets([
Expand Down
16 changes: 8 additions & 8 deletions src/BaseMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Migrations;

use Cake\Console\ConsoleIo;
use Cake\Console\ConsoleIoInterface;
use Cake\Database\Query;
use Cake\Database\Query\DeleteQuery;
use Cake\Database\Query\InsertQuery;
Expand All @@ -34,9 +34,9 @@ class BaseMigration implements MigrationInterface
protected ?AdapterInterface $adapter = null;

/**
* The ConsoleIo instance
* The ConsoleIoInterface instance
*/
protected ?ConsoleIo $io = null;
protected ?ConsoleIoInterface $io = null;

/**
* The config instance.
Expand Down Expand Up @@ -108,7 +108,7 @@ public function getAdapter(): AdapterInterface
/**
* {@inheritDoc}
*/
public function setIo(ConsoleIo $io)
public function setIo(ConsoleIoInterface $io)
{
$this->io = $io;

Expand All @@ -118,7 +118,7 @@ public function setIo(ConsoleIo $io)
/**
* {@inheritDoc}
*/
public function getIo(): ?ConsoleIo
public function getIo(): ?ConsoleIoInterface
{
return $this->io;
}
Expand Down Expand Up @@ -155,7 +155,7 @@ public function getName(): string
* @param int $version Version
* @return $this
*/
public function setVersion(int $version)
public function setVersion(int $version): static
{
$this->validateVersion($version);
$this->version = $version;
Expand All @@ -179,7 +179,7 @@ public function getVersion(): int
* @param bool $isMigratingUp True if the migration is being applied
* @return $this
*/
public function setMigratingUp(bool $isMigratingUp)
public function setMigratingUp(bool $isMigratingUp): static
{
$this->isMigratingUp = $isMigratingUp;

Expand Down Expand Up @@ -448,7 +448,7 @@ public function preFlightCheck(): void
{
if (method_exists($this, MigrationInterface::CHANGE) && (method_exists($this, MigrationInterface::UP) || method_exists($this, MigrationInterface::DOWN))) {
$io = $this->getIo();
if ($io instanceof ConsoleIo) {
if ($io instanceof ConsoleIoInterface) {
$io->out(
'<comment>warning</comment> Migration contains both change() and up()/down() methods.' .
' <warning>Ignoring up() and down()</warning>.',
Expand Down
18 changes: 9 additions & 9 deletions src/BaseSeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Migrations;

use Cake\Console\ConsoleIo;
use Cake\Console\ConsoleIoInterface;
use Migrations\Config\ConfigInterface;
use Migrations\Db\Adapter\AdapterInterface;
use Migrations\Db\Table;
Expand All @@ -29,9 +29,9 @@ class BaseSeed implements SeedInterface
protected ?AdapterInterface $adapter = null;

/**
* The ConsoleIo instance
* The ConsoleIoInterface instance
*/
protected ?ConsoleIo $io = null;
protected ?ConsoleIoInterface $io = null;

/**
* The config instance.
Expand Down Expand Up @@ -78,7 +78,7 @@ public function getAdapter(): AdapterInterface
/**
* {@inheritDoc}
*/
public function setIo(ConsoleIo $io)
public function setIo(ConsoleIoInterface $io)
{
$this->io = $io;

Expand All @@ -88,7 +88,7 @@ public function setIo(ConsoleIo $io)
/**
* {@inheritDoc}
*/
public function getIo(): ?ConsoleIo
public function getIo(): ?ConsoleIoInterface
{
return $this->io;
}
Expand Down Expand Up @@ -223,8 +223,8 @@ public function isIdempotent(): bool
public function call(string $seeder, array $options = []): void
{
$io = $this->getIo();
if (!$io instanceof ConsoleIo) {
throw new RuntimeException('ConsoleIo is required for calling other seeders.');
if (!$io instanceof ConsoleIoInterface) {
throw new RuntimeException('ConsoleIoInterface is required for calling other seeders.');
}
$io->out('');
$io->out(
Expand Down Expand Up @@ -272,8 +272,8 @@ protected function runCall(string $seeder, array $options = []): void
'source' => $options['source'],
]);
$io = $this->getIo();
if (!$io instanceof ConsoleIo) {
throw new RuntimeException('ConsoleIo is required for calling other seeders.');
if (!$io instanceof ConsoleIoInterface) {
throw new RuntimeException('ConsoleIoInterface is required for calling other seeders.');
}
$manager = $factory->createManager($io);
$manager->seed($seeder);
Expand Down
12 changes: 5 additions & 7 deletions src/Command/BakeMigrationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
namespace Migrations\Command;

use Cake\Console\Arguments;
use Cake\Console\ConsoleIo;
use Cake\Console\ConsoleOptionParser;
use Cake\Core\Configure;
use Cake\Event\Event;
Expand All @@ -42,7 +40,7 @@ public static function defaultName(): string
/**
* @inheritDoc
*/
protected function bake(string $name, Arguments $args, ConsoleIo $io): void
protected function bake(string $name): void
{
EventManager::instance()->on('Bake.initialize', function (Event $event): void {
/** @var \Bake\View\BakeView $view */
Expand All @@ -51,7 +49,7 @@ protected function bake(string $name, Arguments $args, ConsoleIo $io): void
});
$this->_name = $name;

parent::bake($name, $args, $io);
parent::bake($name);
}

/**
Expand All @@ -70,18 +68,18 @@ public function template(): string
/**
* @inheritDoc
*/
public function templateData(Arguments $arguments): array
public function templateData(): array
{
$className = $this->_name;
$namespace = Configure::read('App.namespace');
$pluginPath = '';
if ($this->plugin) {
$namespace = $this->_pluginNamespace($this->plugin);
$namespace = $this->pluginNamespace($this->plugin);
$pluginPath = $this->plugin . '.';
}

/** @var array<int, string> $args */
$args = $arguments->getArguments();
$args = $this->args->getArguments();
unset($args[0]);
$columnParser = new ColumnParser();
$fields = $columnParser->parseFields($args);
Expand Down
Loading
Loading