-- Insert a new plugin version into the backend database
--
-- INSTRUCTIONS:
-- 1. Replace <VERSION> with the actual version (e.g., 0.2.1)
-- 2. Replace <DOWNLOAD_URL> with the URL from the GitHub release asset
-- 3. Update CHANGELOG with release notes
-- 4. Run this SQL against the WordChat backend database (Supabase)
--
-- Example download URL format:
-- https://github.com/jeronimodeleon/word-chat-wp-plugin/releases/download/v<VERSION>/wordchat-pro-<VERSION>.zip

INSERT INTO plugin_versions (
    version,
    download_url,
    changelog,
    plugin_slug,
    requires_wp_version,
    requires_php_version,
    tested_wp_version,
    is_stable,
    is_beta,
    released_at
) VALUES (
    '<VERSION>',  -- UPDATE THIS
    '<DOWNLOAD_URL>',  -- UPDATE THIS
    '## What''s New in <VERSION>

- Added Pro license management system
- Implemented automatic plugin updates for Pro users
- Added telemetry and usage tracking for Pro users
- Improved security with server-side API proxy
- Enhanced admin UI with license status display

## Bug Fixes

- Fixed sync status tracking
- Improved error handling in background sync

## Technical Improvements

- Added WordChat_Pro_Updater class for update management
- Implemented license activation/deactivation flow
- Added daily telemetry check-in system
',  -- UPDATE THIS: Changelog text
    'wordchat-pro',
    '5.5',     -- Minimum WordPress version
    '7.4',     -- Minimum PHP version
    '6.4',     -- Tested up to WordPress version
    TRUE,      -- Is this a stable release?
    FALSE,     -- Is this a beta release?
    NOW()      -- Release timestamp
)
ON CONFLICT (version)
DO UPDATE SET
    download_url = EXCLUDED.download_url,
    changelog = EXCLUDED.changelog,
    requires_wp_version = EXCLUDED.requires_wp_version,
    requires_php_version = EXCLUDED.requires_php_version,
    tested_wp_version = EXCLUDED.tested_wp_version,
    is_stable = EXCLUDED.is_stable,
    is_beta = EXCLUDED.is_beta;

-- Verify the insertion
SELECT
    version,
    download_url,
    requires_wp_version,
    requires_php_version,
    tested_wp_version,
    is_stable,
    released_at,
    download_count
FROM plugin_versions
WHERE version = '<VERSION>'
ORDER BY released_at DESC;
