#!/bin/bash
# Simple bash script to fix collation issues
# Run this with: bash run_collation_fix.sh

echo "MySQL Collation Fix Script"
echo "=========================="

# Prompt for database credentials
read -p "MySQL Username (acbptxvs): " DB_USER
DB_USER=${DB_USER:-acbptxvs}

read -p "Database Name (acbptxvs_branch_system): " DB_NAME
DB_NAME=${DB_NAME:-acbptxvs_branch_system}

read -s -p "MySQL Password: " DB_PASS
echo

echo "Applying collation fixes..."

# Run the SQL fix
mysql -u "$DB_USER" -p"$DB_PASS" "$DB_NAME" < fix_collation_sql.sql

if [ $? -eq 0 ]; then
    echo "✓ Collation fix completed successfully!"
    echo "✓ Your Django application should now work without collation errors"
else
    echo "✗ Fix failed. Please check your credentials and try again."
fi