#!/usr/bin/env python
"""
Quick Migration Fix Script
This script quickly resolves the 'Duplicate column name' error by marking
the problematic migration as fake (already applied).
"""
import os
import sys
import django

# Setup Django
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'branch_system.settings')
django.setup()

from django.core.management import call_command

def quick_fix():
    """Quick fix for migration conflict"""
    print("🔧 Quick Migration Fix")
    print("=" * 30)
    
    try:
        # Mark all migrations as fake (already applied)
        print("🔄 Marking all migrations as fake...")
        call_command('migrate', '--fake')
        print("✅ All migrations marked as fake")
        
        # Now try to run migrations normally
        print("🔄 Running migrations normally...")
        call_command('migrate')
        print("✅ Migrations completed successfully")
        
        return True
        
    except Exception as e:
        print(f"❌ Quick fix failed: {str(e)}")
        return False

if __name__ == "__main__":
    print("Quick Migration Fix Script")
    print("This will resolve the 'Duplicate column name' error")
    
    success = quick_fix()
    
    if success:
        print("\n🎉 Migration conflict resolved!")
        print("You can now run the deployment script again.")
    else:
        print("\n❌ Quick fix failed!")
        print("Try the detailed fix script: python fix_migration_conflict.py")
        sys.exit(1)
