9ec0f0e0d6
When the storage.files table already exists from a manual migration, CREATE TABLE IF NOT EXISTS is skipped entirely, so the new media_sort_date column is never added. Add an ALTER TABLE ADD COLUMN IF NOT EXISTS immediately after the CREATE TABLE to handle both fresh and pre-existing databases. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>