-- Fix alembic_version table to point to the latest head
-- This script consolidates the fragmented migration chain
-- Run this if you encounter "multiple heads" error

-- First, check current version
SELECT * FROM alembic_version;

-- Delete all existing version entries (backup first if needed)
-- DELETE FROM alembic_version;

-- Set to the latest consolidated head
-- e1f2g3h4i5j7 is the last proper migration that merges all heads
-- z999_fix_migration_chain is the consolidation migration

-- If you haven't run the new migration yet, use:
UPDATE alembic_version SET version_num = 'e1f2g3h4i5j7';

-- After running the new migration, use:
-- UPDATE alembic_version SET version_num = 'z999_fix_migration_chain';

-- Verify the change
SELECT * FROM alembic_version;
