#!/bin/bash

# Production deployment script to fix M2M table issue
# Run this on the production server

echo "Starting deployment to fix M2M table issue..."

# Navigate to project directory
cd /home/nashmway/nashaajobs-clone

# Activate virtual environment
source /home/nashmway/virtualenv/nashaajobs-clone/3.13/bin/activate

# Apply migrations
echo "Applying migrations..."
python manage.py migrate candidates --settings=config.settings_production

# Check if migration was successful
if [ $? -eq 0 ]; then
    echo "✅ Migration completed successfully!"
    echo "The missing M2M table has been created."
    echo "User deletion should now work without errors."
else
    echo "❌ Migration failed. Please check the logs."
    exit 1
fi

echo "Deployment completed!"