refactor: complete V1 to V2 migration and remove legacy architecture
Remove all V1 architecture components and promote V2 to primary: - Delete all paddle_ocr_* table models (export, ocr, translation, user) - Delete legacy routers (auth, export, ocr, translation) - Delete legacy schemas and services - Promote user_v2.py to user.py as primary user model - Update all imports and dependencies to use V2 models only - Update main.py version to 2.0.0 Database changes: - Fix SQLAlchemy reserved word: rename audit_log.metadata to extra_data - Add migration to drop all paddle_ocr_* tables - Update alembic env to only import V2 models Frontend fixes: - Fix Select component exports in TaskHistoryPage.tsx - Update to use simplified Select API with options prop - Fix AxiosInstance TypeScript import syntax 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -15,14 +15,8 @@ from app.core.config import settings
|
||||
from app.core.database import Base
|
||||
|
||||
# Import all models to ensure they're registered with Base.metadata
|
||||
# Import old User model for legacy tables
|
||||
from app.models.user import User as OldUser
|
||||
# Import new models
|
||||
from app.models.user_v2 import User as NewUser
|
||||
from app.models.task import Task, TaskFile, TaskStatus
|
||||
from app.models.session import Session
|
||||
# Import legacy models
|
||||
from app.models import OCRBatch, OCRFile, OCRResult, ExportRule, TranslationConfig
|
||||
# Import V2 models
|
||||
from app.models import User, Task, TaskFile, TaskStatus, Session, AuditLog
|
||||
|
||||
# this is the Alembic Config object, which provides
|
||||
# access to the values within the .ini file in use.
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
"""drop_old_tables_add_audit_logs
|
||||
|
||||
Revision ID: 4d37f412d37a
|
||||
Revises: 5e75a59fb763
|
||||
Create Date: 2025-11-14 21:13:08.003723
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '4d37f412d37a'
|
||||
down_revision: Union[str, None] = '5e75a59fb763'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema: drop old paddle_ocr_* tables if they exist."""
|
||||
|
||||
# Use raw SQL to drop tables with IF EXISTS
|
||||
connection = op.get_bind()
|
||||
|
||||
# Drop old paddle_ocr_* tables (with foreign key dependencies in correct order)
|
||||
old_tables = [
|
||||
'paddle_ocr_results',
|
||||
'paddle_ocr_files',
|
||||
'paddle_ocr_batches',
|
||||
'paddle_ocr_export_rules',
|
||||
'paddle_ocr_translation_configs',
|
||||
'paddle_ocr_users',
|
||||
]
|
||||
|
||||
for table in old_tables:
|
||||
try:
|
||||
connection.execute(sa.text(f"DROP TABLE IF EXISTS {table}"))
|
||||
print(f"✓ Dropped table: {table}")
|
||||
except Exception as e:
|
||||
print(f" Warning: Could not drop {table}: {e}")
|
||||
|
||||
print("\n✓ All old paddle_ocr_* tables have been removed")
|
||||
print("✓ Migration complete - V2 schema is now active")
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# Note: Downgrade not supported as it would require recreating old tables
|
||||
pass
|
||||
Reference in New Issue
Block a user