<?php
/**
 * Update Form Theme Field - Change 'white' to 'light'
 */

require_once 'config.php';

echo "=== Updating Form Theme Field ===\n\n";

// Check current column definition
$checkCol = $conn->query("SHOW COLUMNS FROM stores LIKE 'form_theme'");
if ($checkCol->num_rows > 0) {
    $colInfo = $checkCol->fetch_assoc();
    echo "Current form_theme type: " . $colInfo['Type'] . "\n";
    
    // Update any existing 'white' values to 'light'
    $updateSql = "UPDATE stores SET form_theme = 'light' WHERE form_theme = 'white'";
    if ($conn->query($updateSql)) {
        $affected = $conn->affected_rows;
        echo "✓ Updated $affected stores from 'white' to 'light'\n";
    }
    
    // Modify column to use 'light' instead of 'white'
    $alterSql = "ALTER TABLE stores MODIFY COLUMN form_theme ENUM('dark', 'light') DEFAULT 'dark'";
    if ($conn->query($alterSql)) {
        echo "✓ Updated form_theme column to use 'light' instead of 'white'\n";
    } else {
        echo "✗ Error updating column: " . $conn->error . "\n";
        exit(1);
    }
} else {
    echo "✗ form_theme column not found!\n";
    exit(1);
}

echo "\n=== Done! ===\n";
?>


