-- Fix uploaded_by and created_by column types to match adminusers.id (TEXT)
-- Date: December 19, 2025
-- Issue: Upload failing with "invalid input syntax for type integer: 'admin-default'"
-- Root cause: adminusers.id is TEXT but uploads.uploaded_by was INTEGER

-- Change uploads.uploaded_by from INTEGER to TEXT
ALTER TABLE uploads ALTER COLUMN uploaded_by TYPE TEXT;

-- Change media_folders.created_by from INTEGER to TEXT
ALTER TABLE media_folders ALTER COLUMN created_by TYPE TEXT;

-- Verify the changes
SELECT 
    'uploads' as table_name, 
    column_name, 
    data_type 
FROM information_schema.columns 
WHERE table_name = 'uploads' 
    AND column_name = 'uploaded_by'
UNION ALL
SELECT 
    'media_folders' as table_name, 
    column_name, 
    data_type 
FROM information_schema.columns 
WHERE table_name = 'media_folders' 
    AND column_name = 'created_by';
