-- Complete fix for loans migration dependencies
-- Run this SQL directly in your MySQL database

-- Remove all problematic loans migrations
DELETE FROM django_migrations WHERE app = 'loans' AND name = '0002_enhance_rollover_request';
DELETE FROM django_migrations WHERE app = 'loans' AND name = '0017_merge_20251002_0238';
DELETE FROM django_migrations WHERE app = 'loans' AND name = '0018_add_rollover_date_field';

-- Ensure rollover_date column exists
ALTER TABLE rollover_requests 
ADD COLUMN IF NOT EXISTS rollover_date DATE NULL 
COMMENT 'Preferred rollover date';

-- Verify the fix
SELECT 'Problematic loans migrations removed!' as status;
SELECT app, name, applied FROM django_migrations WHERE app = 'loans' ORDER BY name;
