connect_error) { throw new Exception("Connection failed: " . $conn->connect_error); } // Check if column already exists $result = $conn->query("SHOW COLUMNS FROM ticket_comments LIKE 'updated_at'"); if ($result->num_rows > 0) { echo "Column 'updated_at' already exists in ticket_comments table.\n"; } else { // Add the column $sql = "ALTER TABLE ticket_comments ADD COLUMN updated_at TIMESTAMP NULL DEFAULT NULL AFTER created_at"; if ($conn->query($sql)) { echo "Successfully added 'updated_at' column to ticket_comments table.\n"; } else { throw new Exception("Failed to add column: " . $conn->error); } } $conn->close(); echo "Done!\n"; } catch (Exception $e) { echo "Error: " . $e->getMessage() . "\n"; exit(1); }