chore(home): mirror from kalinamall (9883e6a) with papatramp URLs

This commit is contained in:
2026-07-14 20:43:52 +10:00
commit ed4e78f6c3
312 changed files with 42790 additions and 0 deletions
+90
View File
@@ -0,0 +1,90 @@
"""initial hosts events api_keys
Revision ID: 001
Revises:
Create Date: 2026-05-26
"""
from typing import Sequence, Union
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql
revision: str = "001"
down_revision: Union[str, None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
op.create_table(
"hosts",
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
sa.Column("agent_instance_id", sa.String(length=128), nullable=True),
sa.Column("hostname", sa.String(length=255), nullable=False),
sa.Column("display_name", sa.String(length=255), nullable=True),
sa.Column("os_family", sa.String(length=32), nullable=False),
sa.Column("os_version", sa.String(length=128), nullable=True),
sa.Column("product", sa.String(length=64), nullable=False),
sa.Column("product_version", sa.String(length=64), nullable=True),
sa.Column("ipv4", sa.String(length=45), nullable=True),
sa.Column("ipv6", sa.String(length=45), nullable=True),
sa.Column("tags", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
sa.Column("use_sac_mode", sa.String(length=32), nullable=True),
sa.Column("last_seen_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("agent_instance_id"),
)
op.create_index("ix_hosts_hostname", "hosts", ["hostname"])
op.create_index("ix_hosts_product", "hosts", ["product"])
op.create_table(
"api_keys",
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
sa.Column("name", sa.String(length=128), nullable=False),
sa.Column("key_prefix", sa.String(length=16), nullable=False),
sa.Column("key_hash", sa.String(length=128), nullable=False),
sa.Column("is_active", sa.Boolean(), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("key_hash"),
)
op.create_index("ix_api_keys_key_prefix", "api_keys", ["key_prefix"])
op.create_table(
"events",
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
sa.Column("event_id", sa.String(length=36), nullable=False),
sa.Column("host_id", sa.Integer(), nullable=False),
sa.Column("occurred_at", sa.DateTime(timezone=True), nullable=False),
sa.Column("received_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.Column("category", sa.String(length=64), nullable=False),
sa.Column("type", sa.String(length=128), nullable=False),
sa.Column("severity", sa.String(length=16), nullable=False),
sa.Column("title", sa.String(length=256), nullable=False),
sa.Column("summary", sa.Text(), nullable=False),
sa.Column("details", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
sa.Column("raw", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
sa.Column("dedup_key", sa.String(length=512), nullable=True),
sa.Column("correlation_id", sa.String(length=36), nullable=True),
sa.Column("payload", postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.ForeignKeyConstraint(["host_id"], ["hosts.id"]),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("event_id", name="uq_events_event_id"),
)
op.create_index("ix_events_event_id", "events", ["event_id"])
op.create_index("ix_events_host_id", "events", ["host_id"])
op.create_index("ix_events_occurred_at", "events", ["occurred_at"])
op.create_index("ix_events_category", "events", ["category"])
op.create_index("ix_events_type", "events", ["type"])
op.create_index("ix_events_severity", "events", ["severity"])
op.create_index("ix_events_dedup_key", "events", ["dedup_key"])
def downgrade() -> None:
op.drop_table("events")
op.drop_table("api_keys")
op.drop_table("hosts")