#!/bin/bash
# Permanent Migration Fix Script for Online Server
# This script safely applies all migrations by faking problematic ones

echo "Starting migration fix process..."

# Fake problematic migrations that have duplicate column errors
echo "Faking problematic migrations..."
python manage.py migrate candidates 0009 --fake 2>/dev/null || echo "Migration candidates.0009 already applied or doesn't need faking"
python manage.py migrate jobs 0002 --fake 2>/dev/null || echo "Migration jobs.0002 already applied or doesn't need faking"
python manage.py migrate jobs 0003 --fake 2>/dev/null || echo "Migration jobs.0003 already applied or doesn't need faking"
python manage.py migrate jobs 0005 --fake 2>/dev/null || echo "Migration jobs.0005 already applied or doesn't need faking"
python manage.py migrate jobs 0006 --fake 2>/dev/null || echo "Migration jobs.0006 already applied or doesn't need faking"

# Now run all migrations
echo "Running all migrations..."
python manage.py migrate

echo "Migration fix complete!"
