INSERT INTO services (node_id, name, status, command)
SELECT $1, $2, $3, $4
WHERE NOT EXISTS (
    SELECT 1 FROM nodes WHERE id = $5
)
RETURNING id;