first commit
This commit is contained in:
68
app/models/migration.py
Normal file
68
app/models/migration.py
Normal file
@@ -0,0 +1,68 @@
|
||||
from pydantic import BaseModel, Field
|
||||
from datetime import datetime
|
||||
from typing import List, Dict, Any, Optional
|
||||
|
||||
|
||||
class MigrationStatus(BaseModel):
|
||||
"""Статус миграции"""
|
||||
is_running: bool = False
|
||||
current_table: Optional[str] = None
|
||||
progress: float = 0.0
|
||||
start_time: Optional[datetime] = None
|
||||
estimated_completion: Optional[datetime] = None
|
||||
|
||||
|
||||
class TableInfo(BaseModel):
|
||||
"""Информация о таблице"""
|
||||
name: str
|
||||
row_count: int
|
||||
last_replication: Optional[datetime] = None
|
||||
columns: List[str] = Field(default_factory=list)
|
||||
has_pk: bool = False
|
||||
has_date_column: bool = False
|
||||
|
||||
|
||||
class MigrationRequest(BaseModel):
|
||||
"""Запрос на миграцию"""
|
||||
tables: Optional[List[str]] = None
|
||||
full_reload: bool = False
|
||||
send_email: bool = True
|
||||
parallel_workers: int = 1
|
||||
|
||||
|
||||
class MigrationResponse(BaseModel):
|
||||
"""Ответ на запрос миграции"""
|
||||
success: bool
|
||||
message: str
|
||||
task_id: Optional[str] = None
|
||||
start_time: datetime = Field(default_factory=datetime.now)
|
||||
|
||||
|
||||
class MigrationReport(BaseModel):
|
||||
"""Отчет о миграции"""
|
||||
summary: Dict[str, Any]
|
||||
successful_tables: List[Dict[str, Any]]
|
||||
failed_tables: List[Dict[str, Any]]
|
||||
schema_changes: List[Dict[str, Any]]
|
||||
errors: List[Dict[str, Any]]
|
||||
|
||||
class Config:
|
||||
json_encoders = {
|
||||
datetime: lambda v: v.isoformat()
|
||||
}
|
||||
|
||||
|
||||
class ColumnInfo(BaseModel):
|
||||
"""Информация о колонке"""
|
||||
name: str
|
||||
type: str
|
||||
nullable: bool
|
||||
max_length: Optional[int] = None
|
||||
default: Optional[str] = None
|
||||
|
||||
|
||||
class SchemaDiff(BaseModel):
|
||||
"""Различия в схемах"""
|
||||
new_columns: List[ColumnInfo] = Field(default_factory=list)
|
||||
missing_columns: List[str] = Field(default_factory=list)
|
||||
type_mismatches: List[Dict[str, str]] = Field(default_factory=list)
|
||||
Reference in New Issue
Block a user