corvid/alembic/versions/0001_tickets_schema.py
caoimhinr 37b2c21720 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>
2026-05-25 19:23:07 +02:00

53 lines
2.4 KiB
Python

"""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")