-- Fix storage_usage table initialization
-- This script safely initializes storage_usage if empty

-- Delete any incomplete records first
DELETE FROM storage_usage WHERE id IS NULL;

-- Insert with explicit UUID generation if table is empty
INSERT INTO storage_usage (id, total_bytes_used, max_bytes_allowed, last_updated)
SELECT
    gen_random_uuid(),
    0,
    10737418240, -- 10GB default
    CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM storage_usage);

-- Verify the record was created
SELECT * FROM storage_usage;
