OptimAIze Database Update"; echo ""; try { $db = Database::getInstance(); echo "
✅ Database connected successfully

"; // Check and add should_pause column to optimization_analysis_state echo "

Updating optimization_analysis_state table

"; $checkColumn = $db->query("SHOW COLUMNS FROM optimization_analysis_state LIKE 'should_pause'"); if ($checkColumn && $checkColumn->num_rows > 0) { echo "
ℹ️ Column 'should_pause' already exists
"; } else { $addColumn = $db->query("ALTER TABLE optimization_analysis_state ADD COLUMN should_pause TINYINT(1) DEFAULT 0 AFTER is_running"); if ($addColumn) { echo "
✅ Added 'should_pause' column successfully
"; } else { echo "
❌ Failed to add 'should_pause' column: " . $db->getLastError() . "
"; } } // Verify all required columns exist echo "

Verifying Required Columns

"; $requiredColumns = [ 'optimization_analysis_state' => ['total_combinations', 'processed_combinations', 'is_running', 'should_pause', 'started_at', 'completed_at', 'last_updated'], 'panel_directives' => ['llm_checked', 'is_impossible', 'llm_reasoning', 'status', 'updated_at'] ]; foreach ($requiredColumns as $table => $columns) { echo "

Table: $table

"; foreach ($columns as $column) { $checkResult = $db->query("SHOW COLUMNS FROM $table LIKE '$column'"); if ($checkResult && $checkResult->num_rows > 0) { echo "
✅ $column
"; } else { echo "
❌ $column (missing)
"; } } echo "
"; } // Check current data status echo "

Current Data Status

"; $totalDirectives = $db->query("SELECT COUNT(*) as count FROM panel_directives")->fetch_assoc()['count']; $checkedDirectives = $db->query("SELECT COUNT(*) as count FROM panel_directives WHERE llm_checked = 1")->fetch_assoc()['count']; $impossibleDirectives = $db->query("SELECT COUNT(*) as count FROM panel_directives WHERE llm_checked = 1 AND is_impossible = 1")->fetch_assoc()['count']; echo "
📊 Total directives: " . number_format($totalDirectives) . "
"; echo "
📊 Checked directives: " . number_format($checkedDirectives) . "
"; echo "
📊 Impossible directives: " . number_format($impossibleDirectives) . "
"; if ($totalDirectives > 0) { $progress = ($checkedDirectives / $totalDirectives) * 100; echo "
📊 Progress: " . number_format($progress, 1) . "%
"; } // Reset any stuck analysis state echo "

Resetting Analysis State

"; $resetResult = $db->query("UPDATE optimization_analysis_state SET is_running = 0, should_pause = 0 WHERE is_running = 1"); if ($resetResult) { echo "
✅ Analysis state reset (any stuck processes stopped)
"; } else { echo "
⚠️ Could not reset analysis state
"; } echo "

Setup Complete!

"; echo "
✅ Database is ready for the enhanced OptimAIze system
"; echo "
ℹ️ You can now use the new OptimAIze page with start/pause functionality
"; echo "

Next Steps:

"; echo "
    "; echo "
  1. Replace your current optimaize.php with the enhanced version
  2. "; echo "
  3. Add the new analysis_control.php file
  4. "; echo "
  5. Add the get_recent_combinations.php file
  6. "; echo "
  7. Replace process_optimization_analysis.php with enhanced_process_optimization.php
  8. "; echo "
  9. Update get_optimization_progress.php with the enhanced version
  10. "; echo "
"; echo "
📋 Performance Notes:
"; echo ""; } catch (Exception $e) { echo "
❌ Database Error: " . htmlspecialchars($e->getMessage()) . "
"; echo "
Please check your database connection and try again.
"; } ?>