fixing errors
Deploy / deploy (push) Successful in 38s

This commit is contained in:
2026-05-07 21:33:21 +02:00
parent bfa69f2a60
commit 8321e3b889
3 changed files with 10 additions and 5 deletions
+2
View File
@@ -364,6 +364,8 @@ function handleComments($method, $id, $db) {
} }
function handleNodes($method, $id, $db) { function handleNodes($method, $id, $db) {
// Ensure node_notes table exists
try { $db->exec("CREATE TABLE IF NOT EXISTS node_notes (node_id INT, notes TEXT DEFAULT '')"); } catch (Exception $e) {}
switch ($method) { switch ($method) {
case 'GET': case 'GET':
echo json_encode($db->query("SELECT n.*, nn.notes FROM network_nodes n LEFT JOIN node_notes nn ON n.id = nn.node_id ORDER BY n.group_name, n.label")->fetchAll(PDO::FETCH_ASSOC)); echo json_encode($db->query("SELECT n.*, nn.notes FROM network_nodes n LEFT JOIN node_notes nn ON n.id = nn.node_id ORDER BY n.group_name, n.label")->fetchAll(PDO::FETCH_ASSOC));
+4 -4
View File
@@ -16,6 +16,7 @@ function getDbConnection() {
} }
function migrate($db) { function migrate($db) {
// Create tables using the main connection
$db->exec("CREATE TABLE IF NOT EXISTS network_shapes ( $db->exec("CREATE TABLE IF NOT EXISTS network_shapes (
id INT AUTO_INCREMENT PRIMARY KEY, id INT AUTO_INCREMENT PRIMARY KEY,
label VARCHAR(255) NOT NULL DEFAULT '', label VARCHAR(255) NOT NULL DEFAULT '',
@@ -38,11 +39,10 @@ function migrate($db) {
role ENUM('admin','user') DEFAULT 'user', role ENUM('admin','user') DEFAULT 'user',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)"); )");
// Connect as root for schema changes
try { try {
$db->exec("CREATE TABLE IF NOT EXISTS node_notes ( $root = new PDO("mysql:host=" . (getenv('DB_HOST') ?: 'mysql') . ";dbname=" . (getenv('DB_NAME') ?: 'neptune') . ";charset=utf8mb4", 'root', getenv('MYSQL_ROOT_PASSWORD') ?: 'neptune_root_pass');
node_id INT PRIMARY KEY, $root->exec("CREATE TABLE IF NOT EXISTS node_notes (node_id INT PRIMARY KEY, notes TEXT DEFAULT '')");
notes TEXT DEFAULT ''
)");
} catch (Exception $e) { } catch (Exception $e) {
} }
} }
+4 -1
View File
@@ -70,7 +70,10 @@ INSERT IGNORE INTO teams (name, color) VALUES
('SOC', '#ffc107'), ('SOC', '#ffc107'),
('Threat Intel', '#198754'); ('Threat Intel', '#198754');
-- Ensure notes column exists and grant ALTER privilege -- Ensure the neptune user has all privileges on neptune database
GRANT ALL PRIVILEGES ON neptune.* TO 'neptune'@'%';
FLUSH PRIVILEGES;
CREATE TABLE IF NOT EXISTS node_notes ( CREATE TABLE IF NOT EXISTS node_notes (
node_id INT PRIMARY KEY, node_id INT PRIMARY KEY,
notes TEXT DEFAULT '' notes TEXT DEFAULT ''