feat(g0v0-migrate): implement g0v0 migration system with plugin support (#97)
For details please view the PR. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
51
packages/g0v0-migrations/g0v0_migrations/model.py
Normal file
51
packages/g0v0-migrations/g0v0_migrations/model.py
Normal file
@@ -0,0 +1,51 @@
|
||||
from pathlib import Path
|
||||
from typing import Annotated, TypedDict
|
||||
|
||||
from alembic.config import Config as AlembicConfig
|
||||
from pydantic import Field
|
||||
from pydantic_settings import BaseSettings
|
||||
from pydantic_settings.main import SettingsConfigDict
|
||||
|
||||
|
||||
class G0v0ServerDatabaseConfig(BaseSettings):
|
||||
model_config: SettingsConfigDict = SettingsConfigDict(
|
||||
extra="ignore",
|
||||
env_file_encoding="utf-8",
|
||||
)
|
||||
|
||||
mysql_host: Annotated[
|
||||
str,
|
||||
Field(default="localhost", description="MySQL 服务器地址"),
|
||||
"数据库设置",
|
||||
]
|
||||
mysql_port: Annotated[
|
||||
int,
|
||||
Field(default=3306, description="MySQL 服务器端口"),
|
||||
"数据库设置",
|
||||
]
|
||||
mysql_database: Annotated[
|
||||
str,
|
||||
Field(default="osu_api", description="MySQL 数据库名称"),
|
||||
"数据库设置",
|
||||
]
|
||||
mysql_user: Annotated[
|
||||
str,
|
||||
Field(default="osu_api", description="MySQL 用户名"),
|
||||
"数据库设置",
|
||||
]
|
||||
mysql_password: Annotated[
|
||||
str,
|
||||
Field(default="password", description="MySQL 密码"),
|
||||
"数据库设置",
|
||||
]
|
||||
|
||||
@property
|
||||
def database_url(self) -> str:
|
||||
return f"mysql+aiomysql://{self.mysql_user}:{self.mysql_password}@{self.mysql_host}:{self.mysql_port}/{self.mysql_database}"
|
||||
|
||||
|
||||
class ContextObject(TypedDict):
|
||||
g0v0_server_path: Path
|
||||
plugin_path: Path
|
||||
alembic_config: AlembicConfig
|
||||
plugin_id: str | None
|
||||
Reference in New Issue
Block a user