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);