From 2b7b45849f2ceb1853ca5b062b9d04db7b51076c Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Wed, 4 Mar 2026 00:38:34 +0530 Subject: [PATCH] Reduce unnecessary ALTER MODIFY by normalizing column signature --- app/Controllers/Setup.php | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/app/Controllers/Setup.php b/app/Controllers/Setup.php index 7fe21a8..65c845c 100644 --- a/app/Controllers/Setup.php +++ b/app/Controllers/Setup.php @@ -1105,12 +1105,29 @@ class Setup extends BaseController private function columnSignature(array $col): string { + $type = strtolower(trim((string) ($col['Type'] ?? ''))); + $type = preg_replace('/\s+/', ' ', $type) ?? $type; + + $nullability = strtoupper(trim((string) ($col['Null'] ?? 'YES'))); + $nullability = $nullability === 'NO' ? 'NO' : 'YES'; + + $default = $col['Default'] ?? null; + if ($default === null) { + $defaultNormalized = '__NULL__'; + } else { + $defaultStr = trim((string) $default); + $upper = strtoupper($defaultStr); + if ($upper === 'CURRENT_TIMESTAMP' || str_starts_with($upper, 'CURRENT_TIMESTAMP(')) { + $defaultNormalized = $upper; + } else { + $defaultNormalized = $defaultStr; + } + } + return json_encode([ - strtolower((string) ($col['Type'] ?? '')), - strtoupper((string) ($col['Null'] ?? 'YES')), - (string) ($col['Default'] ?? ''), - strtolower((string) ($col['Extra'] ?? '')), - (string) ($col['Comment'] ?? ''), + $type, + $nullability, + $defaultNormalized, ]) ?: ''; }