Skip to content

Commit 886c68d

Browse files
authored
Fix various issues for 5.x release (#998)
- Fix README coverage badge pointing to 3.x instead of 5.x - Update MigrationHelper comments (remove outdated phinx TODOs) - Add database-specific limitations documentation - Fix PHPStan issues by adding proper type hints for Bake event subjects - Update PHPStan baseline to remove fixed errors
1 parent f546a48 commit 886c68d

File tree

7 files changed

+88
-26
lines changed

7 files changed

+88
-26
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Migrations plugin for CakePHP
22

33
[![CI](https://github.com/cakephp/migrations/actions/workflows/ci.yml/badge.svg)](https://github.com/cakephp/migrations/actions/workflows/ci.yml)
4-
[![Coverage Status](https://img.shields.io/codecov/c/github/cakephp/migrations/3.x.svg?style=flat-square)](https://app.codecov.io/github/cakephp/migrations/tree/3.x)
4+
[![Coverage Status](https://img.shields.io/codecov/c/github/cakephp/migrations/5.x.svg?style=flat-square)](https://app.codecov.io/github/cakephp/migrations/tree/5.x)
55
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.txt)
66
[![Total Downloads](https://img.shields.io/packagist/dt/cakephp/migrations.svg?style=flat-square)](https://packagist.org/packages/cakephp/migrations)
77

docs/en/writing-migrations.rst

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2315,3 +2315,76 @@ Changing templates
23152315

23162316
See :ref:`custom-seed-migration-templates` for how to customize the templates
23172317
used to generate migrations.
2318+
2319+
Database-Specific Limitations
2320+
=============================
2321+
2322+
While Migrations aims to provide a database-agnostic API, some features have
2323+
database-specific limitations or are not available on all platforms.
2324+
2325+
SQL Server
2326+
----------
2327+
2328+
The following features are not supported on SQL Server:
2329+
2330+
**Check Constraints**
2331+
2332+
Check constraints are not currently implemented for SQL Server. Attempting to
2333+
use ``addCheckConstraint()`` or ``dropCheckConstraint()`` will throw a
2334+
``BadMethodCallException``.
2335+
2336+
**Table Comments**
2337+
2338+
SQL Server does not support table comments. Attempting to use ``changeComment()``
2339+
will throw a ``BadMethodCallException``.
2340+
2341+
**INSERT IGNORE / insertOrSkip()**
2342+
2343+
SQL Server does not support the ``INSERT IGNORE`` syntax used by ``insertOrSkip()``.
2344+
This method will throw a ``RuntimeException`` on SQL Server. Use ``insertOrUpdate()``
2345+
instead for upsert operations, which uses ``MERGE`` statements on SQL Server.
2346+
2347+
SQLite
2348+
------
2349+
2350+
**Foreign Key Names**
2351+
2352+
SQLite does not support named foreign keys. The foreign key constraint name option
2353+
is ignored when creating foreign keys on SQLite.
2354+
2355+
**Table Comments**
2356+
2357+
SQLite does not support table comments directly. Comments are stored as metadata
2358+
but not in the database itself.
2359+
2360+
**Check Constraint Modifications**
2361+
2362+
SQLite does not support ``ALTER TABLE`` operations for check constraints. Adding or
2363+
dropping check constraints requires recreating the entire table, which is handled
2364+
automatically by the adapter.
2365+
2366+
**Table Partitioning**
2367+
2368+
SQLite does not support table partitioning.
2369+
2370+
PostgreSQL
2371+
----------
2372+
2373+
**KEY Partitioning**
2374+
2375+
PostgreSQL does not support MySQL's ``KEY`` partitioning type. Use ``HASH``
2376+
partitioning instead for similar distribution behavior.
2377+
2378+
MySQL/MariaDB
2379+
-------------
2380+
2381+
**insertOrUpdate() Conflict Columns**
2382+
2383+
For MySQL, the ``$conflictColumns`` parameter in ``insertOrUpdate()`` is ignored
2384+
because MySQL's ``ON DUPLICATE KEY UPDATE`` automatically applies to all unique
2385+
constraints. PostgreSQL and SQLite require this parameter to be specified.
2386+
2387+
**MariaDB GIS/Geometry**
2388+
2389+
Some geometry column features may not work correctly on MariaDB due to differences
2390+
in GIS implementation compared to MySQL.

phpstan-baseline.neon

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,5 @@
11
parameters:
22
ignoreErrors:
3-
-
4-
message: '#^Call to an undefined method object\:\:loadHelper\(\)\.$#'
5-
identifier: method.notFound
6-
count: 1
7-
path: src/Command/BakeMigrationCommand.php
8-
9-
-
10-
message: '#^Call to an undefined method object\:\:loadHelper\(\)\.$#'
11-
identifier: method.notFound
12-
count: 1
13-
path: src/Command/BakeMigrationDiffCommand.php
14-
15-
-
16-
message: '#^Call to an undefined method object\:\:loadHelper\(\)\.$#'
17-
identifier: method.notFound
18-
count: 1
19-
path: src/Command/BakeMigrationSnapshotCommand.php
20-
213
-
224
message: '#^PHPDoc tag @var with type string is not subtype of native type non\-falsy\-string\|true\.$#'
235
identifier: varTag.nativeType

src/Command/BakeMigrationCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ public static function defaultName(): string
4848
public function bake(string $name, Arguments $args, ConsoleIo $io): void
4949
{
5050
EventManager::instance()->on('Bake.initialize', function (Event $event): void {
51-
$event->getSubject()->loadHelper('Migrations.Migration');
51+
/** @var \Bake\View\BakeView $view */
52+
$view = $event->getSubject();
53+
$view->loadHelper('Migrations.Migration');
5254
});
5355
$this->_name = $name;
5456

src/Command/BakeMigrationDiffCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ public function bake(string $name, Arguments $args, ConsoleIo $io): void
128128
assert($connection instanceof Connection);
129129

130130
EventManager::instance()->on('Bake.initialize', function (Event $event) use ($collection, $connection): void {
131-
$event->getSubject()->loadHelper('Migrations.Migration', [
131+
/** @var \Bake\View\BakeView $view */
132+
$view = $event->getSubject();
133+
$view->loadHelper('Migrations.Migration', [
132134
'collection' => $collection,
133135
'connection' => $connection,
134136
]);

src/Command/BakeMigrationSnapshotCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ public function bake(string $name, Arguments $args, ConsoleIo $io): void
5959
assert($connection instanceof Connection);
6060

6161
EventManager::instance()->on('Bake.initialize', function (Event $event) use ($collection, $connection): void {
62-
$event->getSubject()->loadHelper('Migrations.Migration', [
62+
/** @var \Bake\View\BakeView $view */
63+
$view = $event->getSubject();
64+
$view->loadHelper('Migrations.Migration', [
6365
'collection' => $collection,
6466
'connection' => $connection,
6567
]);

src/View/Helper/MigrationHelper.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -418,13 +418,14 @@ public function getColumnOption(array $options): array
418418
unset($columnOptions['collate']);
419419
}
420420

421-
// TODO deprecate precision/scale and align with cakephp/database in 5.x
422-
// TODO this can be cleaned up when we stop using phinx data structures for column definitions
421+
// Handle precision/scale conversion between CakePHP's TableSchema format and SQL standard format.
422+
// TableSchema uses: length=total digits, precision=decimal places
423+
// Migrations uses SQL standard: precision=total digits, scale=decimal places
423424
if (!isset($columnOptions['precision']) || $columnOptions['precision'] == null) {
424425
unset($columnOptions['precision']);
425426
} else {
426-
// due to Phinx using different naming for the precision and scale to CakePHP
427-
// Only convert precision to scale if scale is not already set (for decimal columns from diff)
427+
// Convert CakePHP's precision (decimal places) to Migrations' scale
428+
// Only convert if scale is not already set (for decimal columns from diff)
428429
if (!isset($columnOptions['scale'])) {
429430
$columnOptions['scale'] = $columnOptions['precision'];
430431
}

0 commit comments

Comments
 (0)