<?php
require_once dirname(__FILE__) . '/../config.php';
$db = getDB();
$results = [];

// Verificar si columna foto existe
$stmt = $db->query("SHOW COLUMNS FROM inversionista LIKE 'foto'");
$exists = $stmt->fetch(PDO::FETCH_ASSOC);

if (!$exists) {
    $db->exec("ALTER TABLE inversionista ADD COLUMN foto VARCHAR(255) DEFAULT NULL");
    $results[] = "Columna foto creada OK";
} else {
    $results[] = "Columna foto ya existe";
}

// Verificar directorio uploads/profiles
$uploadDir = dirname(__FILE__) . '/../uploads/profiles/';
if (!is_dir($uploadDir)) {
    mkdir($uploadDir, 0755, true);
    $results[] = "Directorio creado";
} else {
    $results[] = "Directorio existe";
}

$results[] = "Writable: " . (is_writable($uploadDir) ? "SI" : "NO");
echo json_encode(["success" => true, "results" => $results]);
