homelab_automation/patch_migrations.py
Bruno Charest 984d06a223
Some checks failed
Tests / Backend Tests (Python) (3.10) (push) Has been cancelled
Tests / Backend Tests (Python) (3.11) (push) Has been cancelled
Tests / Backend Tests (Python) (3.12) (push) Has been cancelled
Tests / Frontend Tests (JS) (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / All Tests Passed (push) Has been cancelled
feat: Implement comprehensive database schema with new models, CRUD operations, and documentation for host metrics, Docker management, and terminal sessions, while removing old test files.
2026-03-05 10:16:13 -05:00

20 lines
617 B
Python

import os
import glob
import re
versions_dir = os.path.join("alembic", "versions")
for py_file in glob.glob(os.path.join(versions_dir, "*.py")):
with open(py_file, "r", encoding="utf-8") as f:
content = f.read()
# Replace sa.String() with sa.String(255)
# except we don't want to replace sa.String(xx) that already have a length
new_content = re.sub(r"sa\.String\(\)", "sa.String(255)", content)
if new_content != content:
print(f"Patched {py_file}")
with open(py_file, "w", encoding="utf-8") as f:
f.write(new_content)
print("Patching complete.")