feat: initial corvid — standalone ticket service extracted from homelab-dashboard
Extracts the ticket/attachment system into a reusable pip-installable package. Centralises homelab MCP server (tickets, attachments, system logs) here. - corvid package: models, router (make_router factory), config, standalone main - Alembic migration chain for fresh standalone deployments - Docker Compose for standalone deployment (port 8090) - mcp_server.py: moved from homelab-dashboard, CORVID_REPO_PATH configurable Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
commit
37b2c21720
27 changed files with 1072 additions and 0 deletions
33
alembic/env.py
Normal file
33
alembic/env.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import asyncio
|
||||
from logging.config import fileConfig
|
||||
|
||||
from sqlalchemy.ext.asyncio import create_async_engine
|
||||
|
||||
from alembic import context
|
||||
|
||||
alembic_cfg = context.config
|
||||
|
||||
if alembic_cfg.config_file_name is not None:
|
||||
fileConfig(alembic_cfg.config_file_name)
|
||||
|
||||
from corvid import config as app_config
|
||||
from corvid.models import Base # noqa: E402 — registers models
|
||||
|
||||
target_metadata = Base.metadata
|
||||
|
||||
|
||||
def do_run_migrations(connection):
|
||||
context.configure(connection=connection, target_metadata=target_metadata)
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
|
||||
async def run_async_migrations():
|
||||
engine = create_async_engine(app_config.DATABASE_URL)
|
||||
async with engine.begin() as conn:
|
||||
await conn.run_sync(do_run_migrations)
|
||||
await engine.dispose()
|
||||
|
||||
|
||||
run_migrations_online = lambda: asyncio.run(run_async_migrations())
|
||||
run_migrations_online()
|
||||
24
alembic/script.py.mako
Normal file
24
alembic/script.py.mako
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
"""${message}
|
||||
|
||||
Revision ID: ${up_revision}
|
||||
Revises: ${down_revision | comma,n}
|
||||
Create Date: ${create_date}
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
${imports if imports else ""}
|
||||
|
||||
revision: str = ${repr(up_revision)}
|
||||
down_revision: Union[str, None] = ${repr(down_revision)}
|
||||
branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
|
||||
depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
${upgrades if upgrades else "pass"}
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
${downgrades if downgrades else "pass"}
|
||||
53
alembic/versions/0001_tickets_schema.py
Normal file
53
alembic/versions/0001_tickets_schema.py
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
"""tickets and ticket_attachments initial schema
|
||||
|
||||
Revision ID: 0001
|
||||
Revises:
|
||||
Create Date: 2026-05-25
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
revision: str = "0001"
|
||||
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(
|
||||
"tickets",
|
||||
sa.Column("id", sa.Integer(), primary_key=True),
|
||||
sa.Column("guid", sa.String(36), nullable=False, unique=True),
|
||||
sa.Column("user", sa.String(64), nullable=False, server_default="kevin"),
|
||||
sa.Column("title", sa.String(256), nullable=False),
|
||||
sa.Column("description", sa.Text(), nullable=True),
|
||||
sa.Column("submitted_at", sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column("status", sa.String(16), nullable=False, server_default="open"),
|
||||
sa.Column("type", sa.String(16), nullable=False, server_default="feature"),
|
||||
sa.Column("parent_id", sa.Integer(),
|
||||
sa.ForeignKey("tickets.id", ondelete="SET NULL"), nullable=True),
|
||||
sa.Column("effort", sa.Integer(), nullable=True),
|
||||
sa.Column("startup_script", sa.Text(), nullable=True),
|
||||
)
|
||||
op.create_index("ix_tickets_parent_id", "tickets", ["parent_id"])
|
||||
|
||||
op.create_table(
|
||||
"ticket_attachments",
|
||||
sa.Column("id", sa.Integer(), primary_key=True),
|
||||
sa.Column("ticket_id", sa.Integer(),
|
||||
sa.ForeignKey("tickets.id", ondelete="CASCADE"), nullable=False),
|
||||
sa.Column("title", sa.String(256), nullable=False),
|
||||
sa.Column("content", sa.Text(), nullable=False),
|
||||
sa.Column("created_by", sa.String(64), nullable=False, server_default="kevin"),
|
||||
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
|
||||
)
|
||||
op.create_index("ix_ticket_attachments_ticket_id", "ticket_attachments", ["ticket_id"])
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_index("ix_ticket_attachments_ticket_id", table_name="ticket_attachments")
|
||||
op.drop_table("ticket_attachments")
|
||||
op.drop_index("ix_tickets_parent_id", table_name="tickets")
|
||||
op.drop_table("tickets")
|
||||
Loading…
Add table
Add a link
Reference in a new issue