# ONE-LINER COMMAND TO FIX UUID COLUMN TYPES
# Run this in your cPanel terminal/SSH

cd /home/acbptxvs/public_html/branchbusinessadvance.co.ke && python3 -c "
import os, django
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'branch_system.settings')
django.setup()
from django.db import connection
with connection.cursor() as cursor:
    cursor.execute('SELECT COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = \"portfolio_assignments\" AND COLUMN_NAME IN (\"client_id\", \"portfolio_manager_id\", \"assigned_by_id\")')
    columns = cursor.fetchall()
    print('Current column types:', columns)
    for col_name, data_type in columns:
        if data_type == 'int':
            with connection.cursor() as fix_cursor:
                fix_cursor.execute(f'ALTER TABLE portfolio_assignments MODIFY COLUMN {col_name} CHAR(36) NULL')
                print(f'Fixed {col_name} to CHAR(36)')
        else:
            print(f'{col_name} already correct: {data_type}')
" && echo "UUID COLUMNS FIXED!"
