a7a281cb11
First-party plugins (host_agent, http, snmp, traefik, unifi, docker) are now tracked under plugins/ and baked into the image, so they version atomically with core — ending the cross-repo import drift the roundtable->steward rename exposed. History for these files is preserved in the archived Roundtable-plugins repo. Plugin discovery becomes multi-root: PLUGIN_DIR (single) -> PLUGIN_DIRS (bundled first, then external) + PLUGIN_INSTALL_DIR. Bundled ships in the image; third-party plugins still mount at runtime into the external root (STEWARD_PLUGIN_DIR, default /data/plugins) and downloads/installs land there. Bundled shadows external on a name collision. - config.py: load_bootstrap returns plugin_dirs + plugin_install_dir - app.py: iterate PLUGIN_DIRS at the migration + load sites - migration_runner.py: discover_all_in() unions every plugin root - plugin_manager.py: resolve_plugin_path() (pure, first-root-wins); load / install / hot-reload span all roots; installs target the external root - settings/routes.py: _discover_plugins scans all roots, dedup bundled-first - Dockerfile: COPY plugins/ ; docker-compose: drop host bind, document external - tests/test_plugin_dirs.py: resolution, multi-root discovery, bootstrap split Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
63 lines
2.7 KiB
Python
63 lines
2.7 KiB
Python
"""UniFi plugin initial tables
|
|
|
|
Revision ID: unifi_001_initial
|
|
Revises: (none — branch off core via depends_on)
|
|
Create Date: 2026-03-20
|
|
"""
|
|
from typing import Sequence, Union
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
revision: str = "unifi_001_initial"
|
|
down_revision: Union[str, None] = None
|
|
branch_labels: Union[str, Sequence[str], None] = "unifi"
|
|
depends_on: Union[str, Sequence[str], None] = ("0004_app_settings",)
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.create_table(
|
|
"unifi_wan_stats",
|
|
sa.Column("id", sa.String(36), primary_key=True),
|
|
sa.Column("scraped_at", sa.DateTime(timezone=True), nullable=False),
|
|
sa.Column("is_up", sa.Boolean, nullable=False, server_default="false"),
|
|
sa.Column("wan_ip", sa.String(64), nullable=True),
|
|
sa.Column("latency_ms", sa.Float, nullable=True),
|
|
sa.Column("rx_bytes_rate", sa.Float, nullable=True),
|
|
sa.Column("tx_bytes_rate", sa.Float, nullable=True),
|
|
sa.Column("uptime_seconds", sa.Integer, nullable=True),
|
|
)
|
|
op.create_index("ix_unifi_wan_stats_scraped", "unifi_wan_stats", ["scraped_at"])
|
|
|
|
op.create_table(
|
|
"unifi_client_snapshots",
|
|
sa.Column("id", sa.String(36), primary_key=True),
|
|
sa.Column("scraped_at", sa.DateTime(timezone=True), nullable=False),
|
|
sa.Column("total_clients", sa.Integer, nullable=False, server_default="0"),
|
|
sa.Column("wireless_clients", sa.Integer, nullable=False, server_default="0"),
|
|
sa.Column("wired_clients", sa.Integer, nullable=False, server_default="0"),
|
|
sa.Column("guest_clients", sa.Integer, nullable=False, server_default="0"),
|
|
sa.Column("top_clients_json", sa.Text, nullable=False, server_default="[]"),
|
|
)
|
|
op.create_index("ix_unifi_client_snapshots_scraped", "unifi_client_snapshots", ["scraped_at"])
|
|
|
|
op.create_table(
|
|
"unifi_devices",
|
|
sa.Column("mac", sa.String(32), primary_key=True),
|
|
sa.Column("name", sa.String(255), nullable=True),
|
|
sa.Column("model", sa.String(64), nullable=True),
|
|
sa.Column("device_type", sa.String(16), nullable=True),
|
|
sa.Column("ip", sa.String(64), nullable=True),
|
|
sa.Column("state", sa.Integer, nullable=False, server_default="0"),
|
|
sa.Column("uptime_seconds", sa.Integer, nullable=True),
|
|
sa.Column("last_seen", sa.DateTime(timezone=True), nullable=True),
|
|
sa.Column("scraped_at", sa.DateTime(timezone=True), nullable=False),
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_table("unifi_devices")
|
|
op.drop_index("ix_unifi_client_snapshots_scraped", "unifi_client_snapshots")
|
|
op.drop_table("unifi_client_snapshots")
|
|
op.drop_index("ix_unifi_wan_stats_scraped", "unifi_wan_stats")
|
|
op.drop_table("unifi_wan_stats")
|