-- =============================================
-- MIGRATION: Media Assets Table
-- Tracks uploaded media files (images, videos) for the CMS Media Library
-- =============================================

CREATE TABLE IF NOT EXISTS media_assets (
    id VARCHAR(100) PRIMARY KEY,
    file_name VARCHAR(255) NOT NULL,
    file_url VARCHAR(1000) NOT NULL,
    file_type VARCHAR(100) NOT NULL,
    file_size INT NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- Seed with a sample image if empty, to demonstrate functionality (optional, but good for first view)
INSERT IGNORE INTO media_assets (id, file_name, file_url, file_type, file_size)
VALUES (
    'seed-sample-image-1',
    'luxury-villa.webp',
    'https://images.unsplash.com/photo-1600596542815-ffad4c1539a9?auto=format&fit=crop&q=80&w=800',
    'image/webp',
    124500
);

-- Verification
SELECT 'media_assets' AS tbl, COUNT(*) AS row_count FROM media_assets;
