-- Site Builder Projects table
-- Tracks which WHP sites have site-builder projects (1:1 relationship with sites)
CREATE TABLE IF NOT EXISTS whp.site_builder_projects (
    id INT AUTO_INCREMENT PRIMARY KEY,
    site_id INT NOT NULL COMMENT 'FK to sites.id - the WHP site this project belongs to',
    username VARCHAR(32) NOT NULL COMMENT 'Owner username for quick lookups',
    name VARCHAR(255) NOT NULL DEFAULT 'Untitled Site' COMMENT 'Project display name',
    page_count INT DEFAULT 1 COMMENT 'Number of pages in the project',
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    UNIQUE KEY unique_site_project (site_id),
    INDEX idx_username (username),
    FOREIGN KEY (site_id) REFERENCES sites(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
