<?php
require_once __DIR__ . '/config.php';
$db = db();

try {
    // 1. Create Profiles table
    $db->exec("CREATE TABLE IF NOT EXISTS celestial_object_status_profiles (
        id INT AUTO_INCREMENT PRIMARY KEY,
        name VARCHAR(255) NOT NULL,
        slug VARCHAR(255) NOT NULL UNIQUE,
        enabled TINYINT(1) DEFAULT 1,
        priority INT DEFAULT 0,
        scope_object_type VARCHAR(50) NULL,
        config JSON NULL,
        created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
        updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
    )");
    echo "Table 'celestial_object_status_profiles' created or already exists.\n";

    // 2. Add status_profile_id to planets
    $db->exec("ALTER TABLE planets ADD COLUMN IF NOT EXISTS status_profile_id INT NULL AFTER status");
    echo "Column 'status_profile_id' added to 'planets' table.\n";

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

