1
0

fix_dead_references.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import os
  2. # 1. Update start_batch_ingest.sh
  3. file1 = "start_batch_ingest.sh"
  4. if os.path.exists(file1):
  5. with open(file1, "r", encoding="utf-8", errors="replace") as f:
  6. content = f.read()
  7. content = content.replace("Lange FranA ois", "Francois Lange")
  8. content = content.replace("Lange FranAois", "Francois Lange")
  9. content = content.replace("Lange François", "Francois Lange")
  10. old_block = """echo "dYs? Starting database wipe and reset..."
  11. # Automatically run the new DB setup to drop the rigid table
  12. venv/bin/python3 setup_db.py"""
  13. new_block = """echo "dYs? Running database migrations to ensure schema health..."
  14. venv/bin/python3 -m alembic upgrade head"""
  15. content = content.replace(old_block, new_block)
  16. with open(file1, "w", encoding="utf-8") as f:
  17. f.write(content)
  18. print("Updated start_batch_ingest.sh")
  19. # 2. Update master_trigger.sh
  20. file2 = "master_trigger.sh"
  21. if os.path.exists(file2):
  22. with open(file2, "r", encoding="utf-8", errors="replace") as f:
  23. content = f.read()
  24. content = content.replace("Lange FranA ois", "Francois Lange")
  25. content = content.replace("Lange FranAois", "Francois Lange")
  26. content = content.replace("Lange François", "Francois Lange")
  27. content = content.replace("python3 setup_db.py", "python3 -m alembic upgrade head")
  28. with open(file2, "w", encoding="utf-8") as f:
  29. f.write(content)
  30. print("Updated master_trigger.sh")
  31. # 3. Update deploy.sh
  32. file3 = "deploy.sh"
  33. if os.path.exists(file3):
  34. with open(file3, "r", encoding="utf-8", errors="replace") as f:
  35. content = f.read()
  36. content = content.replace("Lange FranA ois", "Francois Lange")
  37. content = content.replace("Lange FranAois", "Francois Lange")
  38. content = content.replace("Lange François", "Francois Lange")
  39. old_deploy_end = """echo "Next steps:"
  40. echo "1. Activate your virtual environment manually: source venv/bin/activate"
  41. echo "2. Check your config.ini file details."
  42. echo "3. Run your setup script to configure database users: python setup_db.py\""""
  43. new_deploy_end = """echo "Next steps:"
  44. echo "1. Activate your virtual environment manually: source venv/bin/activate"
  45. echo "2. Check your .env file details."
  46. echo "3. Run database migrations: alembic upgrade head\""""
  47. content = content.replace(old_deploy_end, new_deploy_end)
  48. with open(file3, "w", encoding="utf-8") as f:
  49. f.write(content)
  50. print("Updated deploy.sh")