Add Migration schema
This commit is contained in:
parent
58f6012a0b
commit
5b6bfbfb9c
38
schemas/migration.py
Normal file
38
schemas/migration.py
Normal file
@ -0,0 +1,38 @@
|
||||
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"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user