Heray-Was-Here
Server : LiteSpeed
System : Linux uk-fast-web1372.main-hosting.eu 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User : u390967363 ( 390967363)
PHP Version : 8.2.30
Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
Directory :  /home/u390967363/domains/aibenproperties.com/public_html/app/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/u390967363/domains/aibenproperties.com/public_html/app/debug_task_schema.php
<?php
require_once 'includes/db.php';

echo "Checking Task Schema...\n";

try {
    $stmt = $pdo->query("DESCRIBE tasks");
    $columns = $stmt->fetchAll(PDO::FETCH_COLUMN);
    echo "Current Columns: " . implode(", ", $columns) . "\n";
    
    // 1. Add Property ID
    if (!in_array('property_id', $columns)) {
        echo "Adding property_id...\n";
        $pdo->exec("ALTER TABLE tasks ADD COLUMN property_id INT NULL AFTER created_by");
        // Try adding foreign key, might fail if data exists that violates it, so wrap in try/catch or just leave loose for now
        try {
             $pdo->exec("ALTER TABLE tasks ADD CONSTRAINT fk_tasks_property FOREIGN KEY (property_id) REFERENCES properties(id) ON DELETE SET NULL");
        } catch (Exception $ex) { echo "FK Error (Property): " . $ex->getMessage() . "\n"; }
    }

    // 2. Add Client ID
    if (!in_array('client_id', $columns)) {
        echo "Adding client_id...\n";
        $pdo->exec("ALTER TABLE tasks ADD COLUMN client_id INT NULL AFTER property_id");
         try {
             $pdo->exec("ALTER TABLE tasks ADD CONSTRAINT fk_tasks_client FOREIGN KEY (client_id) REFERENCES users(id) ON DELETE SET NULL");
        } catch (Exception $ex) { echo "FK Error (Client): " . $ex->getMessage() . "\n"; }
    }

    // 3. Add Updated At
    if (!in_array('updated_at', $columns)) {
        echo "Adding updated_at...\n";
        $pdo->exec("ALTER TABLE tasks ADD COLUMN updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP AFTER created_at");
    }

    echo "Schema update complete.\n";

} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}
?>

Hry