#!/usr/bin/env python3
"""
Check the exact data type of loans.id column
"""

import os
import sys
import django

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

from django.db import connection

def get_column_type(table_name, column_name):
    """Get the exact data type of a specific column"""
    with connection.cursor() as cursor:
        cursor.execute("""
            SELECT DATA_TYPE, COLUMN_TYPE, CHARACTER_MAXIMUM_LENGTH, IS_NULLABLE
            FROM information_schema.columns 
            WHERE table_schema = DATABASE() 
            AND table_name = %s 
            AND column_name = %s
        """, [table_name, column_name])
        return cursor.fetchone()

def main():
    print("=== CHECKING LOANS.ID COLUMN TYPE ===")
    loans_id_info = get_column_type('loans', 'id')
    if loans_id_info:
        print(f"Data Type: {loans_id_info[0]}")
        print(f"Column Type: {loans_id_info[1]}")
        print(f"Max Length: {loans_id_info[2]}")
        print(f"Nullable: {loans_id_info[3]}")
    else:
        print("Column not found!")
    
    print("\n=== CHECKING LOAN_APPLICATIONS.ID COLUMN TYPE ===")
    loan_app_id_info = get_column_type('loan_applications', 'id')
    if loan_app_id_info:
        print(f"Data Type: {loan_app_id_info[0]}")
        print(f"Column Type: {loan_app_id_info[1]}")
        print(f"Max Length: {loan_app_id_info[2]}")
        print(f"Nullable: {loan_app_id_info[3]}")
    else:
        print("Column not found!")

if __name__ == "__main__":
    main()
