-- Blog Backup Database Schema
-- Run this SQL in Supabase Dashboard SQL Editor

-- Add audio URL column for storing podcast audio file URLs
ALTER TABLE blog_messages 
ADD COLUMN IF NOT EXISTS audio_url TEXT;

-- Add audio duration column (in seconds)
ALTER TABLE blog_messages 
ADD COLUMN IF NOT EXISTS audio_duration INTEGER;

-- Create index for faster queries on posts with audio
CREATE INDEX IF NOT EXISTS idx_blog_messages_audio 
ON blog_messages(audio_url) 
WHERE audio_url IS NOT NULL;

COMMENT ON COLUMN blog_messages.audio_url IS 'Public URL to the audio file in Supabase Storage';
COMMENT ON COLUMN blog_messages.audio_duration IS 'Audio duration in seconds (estimated from file size)';

-- Verify columns were added
SELECT column_name, data_type 
FROM information_schema.columns 
WHERE table_name = 'blog_messages' 
ORDER BY ordinal_position;