From fc6b878bb304e0f4e86b03862ca38ca64b82b04a Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Wed, 4 Mar 2026 00:48:52 +0530 Subject: [PATCH] Normalize integer type widths in schema compare to avoid false MODIFY --- app/Controllers/Setup.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/app/Controllers/Setup.php b/app/Controllers/Setup.php index 65c845c..33d0c42 100644 --- a/app/Controllers/Setup.php +++ b/app/Controllers/Setup.php @@ -1105,8 +1105,7 @@ class Setup extends BaseController private function columnSignature(array $col): string { - $type = strtolower(trim((string) ($col['Type'] ?? ''))); - $type = preg_replace('/\s+/', ' ', $type) ?? $type; + $type = $this->normalizeColumnTypeForCompare((string) ($col['Type'] ?? '')); $nullability = strtoupper(trim((string) ($col['Null'] ?? 'YES'))); $nullability = $nullability === 'NO' ? 'NO' : 'YES'; @@ -1131,6 +1130,23 @@ class Setup extends BaseController ]) ?: ''; } + private function normalizeColumnTypeForCompare(string $type): string + { + $type = strtolower(trim($type)); + $type = preg_replace('/\s+/', ' ', $type) ?? $type; + + if ($type === '') { + return ''; + } + + // MySQL/MariaDB may report integer display width differently: int vs int(11), int unsigned vs int(10) unsigned. + // Ignore only integer display width for comparison to avoid false-positive MODIFY statements. + $type = preg_replace('/\b(tinyint|smallint|mediumint|int|integer|bigint)\s*\(\s*\d+\s*\)/i', '$1', $type) ?? $type; + $type = preg_replace('/\s+/', ' ', $type) ?? $type; + + return trim($type); + } + private function ensureCreateTableIfNotExists(string $sql): string { $sql = trim($sql);