38 lines
1.5 KiB
Python
38 lines
1.5 KiB
Python
from pydantic import BaseModel, Field
|
|
from typing import Optional
|
|
from datetime import datetime
|
|
|
|
class MigrationBase(BaseModel):
|
|
version: str = Field(..., description="Migration version identifier", index=True)
|
|
description: Optional[str] = Field(None, description="Migration description")
|
|
applied: bool = Field(False, description="Whether the migration has been applied")
|
|
script_path: str = Field(..., description="Path to the migration script file")
|
|
checksum: Optional[str] = Field(None, description="Migration file checksum")
|
|
execution_time: Optional[datetime] = Field(None, description="When the migration was executed")
|
|
|
|
class MigrationCreate(MigrationBase):
|
|
class Config:
|
|
schema_extra = {
|
|
"example": {
|
|
"version": "v1.0.0",
|
|
"description": "Initial schema migration",
|
|
"applied": False,
|
|
"script_path": "/migrations/v1_0_0_initial.sql",
|
|
"checksum": "a1b2c3d4e5f6",
|
|
"execution_time": "2023-01-01T00:00:00"
|
|
}
|
|
}
|
|
|
|
class Migration(MigrationBase):
|
|
class Config:
|
|
orm_mode = True
|
|
schema_extra = {
|
|
"example": {
|
|
"version": "v1.0.0",
|
|
"description": "Initial schema migration",
|
|
"applied": True,
|
|
"script_path": "/migrations/v1_0_0_initial.sql",
|
|
"checksum": "a1b2c3d4e5f6",
|
|
"execution_time": "2023-01-01T00:00:00"
|
|
}
|
|
} |