feat: AppSetting model and migration 0004
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
"""App settings table
|
||||
|
||||
Revision ID: 0004_app_settings
|
||||
Revises: 0003_ansible_runs
|
||||
Create Date: 2026-03-18
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
revision: str = "0004_app_settings"
|
||||
down_revision: Union[str, None] = "0003_ansible_runs"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.create_table(
|
||||
"app_settings",
|
||||
sa.Column("key", sa.String(128), primary_key=True),
|
||||
sa.Column("value_json", sa.Text, nullable=False),
|
||||
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=False),
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_table("app_settings")
|
||||
@@ -5,6 +5,7 @@ from .monitors import PingResult, DnsResult, PingStatus, DnsStatus
|
||||
from .metrics import PluginMetric
|
||||
from .alerts import AlertRule, AlertState, AlertEvent, AlertOperator, AlertStateEnum
|
||||
from .ansible import AnsibleRun, AnsibleRunStatus
|
||||
from .settings import AppSetting
|
||||
|
||||
__all__ = [
|
||||
"Base", "User",
|
||||
@@ -13,4 +14,5 @@ __all__ = [
|
||||
"PluginMetric",
|
||||
"AlertRule", "AlertState", "AlertEvent", "AlertOperator", "AlertStateEnum",
|
||||
"AnsibleRun", "AnsibleRunStatus",
|
||||
"AppSetting",
|
||||
]
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
from __future__ import annotations
|
||||
from datetime import datetime, timezone
|
||||
from sqlalchemy import DateTime, String, Text
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
from fablednetmon.models.base import Base
|
||||
|
||||
|
||||
class AppSetting(Base):
|
||||
__tablename__ = "app_settings"
|
||||
|
||||
key: Mapped[str] = mapped_column(String(128), primary_key=True)
|
||||
value_json: Mapped[str] = mapped_column(Text, nullable=False)
|
||||
updated_at: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True),
|
||||
nullable=False,
|
||||
default=lambda: datetime.now(timezone.utc),
|
||||
onupdate=lambda: datetime.now(timezone.utc),
|
||||
)
|
||||
@@ -12,7 +12,7 @@ import sqlalchemy as sa
|
||||
revision: str = "traefik_001_initial"
|
||||
down_revision: Union[str, None] = None
|
||||
branch_labels: Union[str, Sequence[str], None] = "traefik"
|
||||
depends_on: Union[str, Sequence[str], None] = ("0003_ansible_runs",)
|
||||
depends_on: Union[str, Sequence[str], None] = ("0004_app_settings",)
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
|
||||
Reference in New Issue
Block a user