0) { @ob_end_clean(); } header('Content-Type: application/json; charset=utf-8'); header('X-Content-Type-Options: nosniff'); header('Cache-Control: no-store'); require_once __DIR__ . '/../core.php'; $report = []; try { $db = getDB('web'); // 1. 看当前列类型 $cur = $db->query("SHOW COLUMNS FROM rules_ack WHERE Field = 'signed_content'")->fetchArray(); $report['current_type'] = $cur ? $cur['Type'] : '(列不存在)'; // 2. 已是 MEDIUMTEXT / LONGTEXT / TEXT → 跳过 if ($cur) { $t = strtolower($cur['Type']); if (strpos($t, 'mediumtext') !== false || strpos($t, 'longtext') !== false || strpos($t, 'text') !== false) { $report['action'] = 'skip_already_text'; $report['success'] = true; echo json_encode($report, JSON_UNESCAPED_UNICODE); exit; } } // 3. ALTER 到 MEDIUMTEXT(与 db_schema_mysql.sql 对齐;16MB 上限足够装 150 行协议) $db->exec("ALTER TABLE rules_ack MODIFY COLUMN signed_content MEDIUMTEXT"); $report['action'] = 'altered_to_mediumtext'; // 4. 复核 $new = $db->query("SHOW COLUMNS FROM rules_ack WHERE Field = 'signed_content'")->fetchArray(); $report['new_type'] = $new ? $new['Type'] : '(?)'; $report['success'] = true; } catch (\Throwable $e) { $report['success'] = false; $report['error'] = $e->getMessage(); } echo json_encode($report, JSON_UNESCAPED_UNICODE);