Sindbad~EG File Manager

Current Path : /home/copmadinaarea/thecopmadinaarea.org/conference/
Upload File :
Current File : /home/copmadinaarea/thecopmadinaarea.org/conference/apply_custom_table_schema.php

<?php
// ===== DYNAMIC TABLE CREATION FEATURE - SCHEMA APPLICATION =====
// Apply database schema changes for custom table functionality

require_once 'includes/functions.php';

// For direct execution - comment out authentication check
// if (!isLoggedIn() || !hasRole('superuser')) {
//     die('Access denied. Superuser privileges required.');
// }

$db = new CopMadinaDB();
$conn = $db->getConnection();

try {
    echo "Applying custom table schema changes...\n";
    
    // Check if column already exists
    $check_sql = "SHOW COLUMNS FROM events LIKE 'custom_table_name'";
    $result = $conn->query($check_sql);
    
    if ($result->rowCount() == 0) {
        // Add custom_table_name column
        $alter_sql = "ALTER TABLE `events` ADD COLUMN `custom_table_name` VARCHAR(64) DEFAULT NULL AFTER `form_template_id`";
        $conn->exec($alter_sql);
        echo "✓ Added custom_table_name column to events table\n";
        
        // Add index
        $index_sql = "ALTER TABLE `events` ADD INDEX `idx_custom_table_name` (`custom_table_name`)";
        $conn->exec($index_sql);
        echo "✓ Added index for custom_table_name column\n";
    } else {
        echo "✓ custom_table_name column already exists\n";
    }
    
    echo "\nSchema changes applied successfully!\n";
    echo "You can now create events with dynamic tables.\n";
    
} catch (Exception $e) {
    echo "Error applying schema changes: " . $e->getMessage() . "\n";
}
// ===== END DYNAMIC TABLE CREATION FEATURE =====
?>

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists