File size: 1,135 Bytes
457b685 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
#!/usr/bin/env python
"""
Fix the user_id issue in translation service.
The User.id is a string but the foreign key expects a UUID.
"""
import sys
import os
from pathlib import Path
# Add backend to path
backend_path = Path(__file__).parent
sys.path.insert(0, str(backend_path))
# Read the translation_openai.py file
file_path = backend_path / "src" / "models" / "translation_openai.py"
content = file_path.read_text(encoding='utf-8')
# Change user_id from UUID to String to match the User model
content = content.replace(
'user_id = Column(UUID(as_uuid=True), ForeignKey("users.id"), nullable=True, index=True)',
'user_id = Column(String(36), ForeignKey("users.id"), nullable=True, index=True)'
)
# Also fix TranslationSession and TranslationMetrics user_id fields
content = content.replace(
'user_id = Column(UUID(as_uuid=True), ForeignKey("users.id"), nullable=True, index=True)',
'user_id = Column(String(36), ForeignKey("users.id"), nullable=True, index=True)'
)
# Write back to file
file_path.write_text(content, encoding='utf-8')
print("Fixed user_id to use String instead of UUID to match User.id field") |