#!/bin/bash

# Remove port allocations for app from network_resources table
portsRemoveFromDatabase()
{
    local app_name="$1"
    
    if [[ -z "$app_name" ]]; then
        isError "App name is required for port removal"
    else
        # Delete port allocations for this app
        local result=$(sqlite3 "$docker_dir/$db_file" "DELETE FROM network_resources WHERE app_name = '$app_name' AND resource_type = 'port';" 2>/dev/null)
        
        if [[ $? -eq 0 ]]; then
            isSuccessful "Removed port allocations for $app_name"
        else
            isError "Failed to remove port allocations for $app_name"
        fi
    fi
}
