View file File name : update_db.php Content :<?php require 'db_config.php'; header('Content-Type: text/plain'); echo "Omni Rewards - Database Updater for Primary Color\n"; echo "=================================================\n\n"; try { $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { throw new Exception("Connection failed: " . $conn->connect_error); } echo "Successfully connected to the database.\n\n"; $table_name = 'business_settings'; $column_name = 'primaryColor'; $column_definition = "VARCHAR(50) NULL DEFAULT '262 83% 57%'"; // Check if the column already exists $existing_columns = []; $result = $conn->query("SHOW COLUMNS FROM `$table_name`"); if ($result) { while ($row = $result->fetch_assoc()) { $existing_columns[] = $row['Field']; } } else { throw new Exception("Could not describe table `$table_name`. Does it exist?"); } echo "Checking for column `$column_name` in table `$table_name`...\n"; if (!in_array($column_name, $existing_columns)) { $sql = "ALTER TABLE `$table_name` ADD COLUMN `$column_name` $column_definition"; echo "Attempting to add column: `$column_name`... "; if ($conn->query($sql) === TRUE) { echo "SUCCESS.\n"; echo "\n---------------------------------------\n"; echo "Database schema updated successfully.\n"; } else { throw new Exception("Error adding column `$column_name`: " . $conn->error); } } else { echo "Column `$column_name` already exists. No changes needed.\n"; echo "\n---------------------------------------\n"; echo "Database schema appears to be up to date.\n"; } echo "You can now safely delete this file (update_db.php).\n"; $conn->close(); } catch (Exception $e) { http_response_code(500); echo "\n\nAN ERROR OCCURRED:\n" . $e->getMessage() . "\n"; } ?>