- Add TrustedHostMiddleware for Host header validation - Add CORSMiddleware with configurable origins - Add rate limiting with RateLimitExceeded handler - Add custom middleware for security headers (HSTS, X-Frame-Options, etc.) - Add /health/db endpoint that checks database connectivity - Mark health endpoints as rate limit exempt - Fix linting issues in migration file (Rule 3 - Blocking)
68 lines
2.1 KiB
Python
68 lines
2.1 KiB
Python
"""Create build table
|
|
|
|
Revision ID: de1460a760b0
|
|
Revises:
|
|
Create Date: 2026-01-25 20:11:11.446731
|
|
|
|
"""
|
|
|
|
from collections.abc import Sequence
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = "de1460a760b0"
|
|
down_revision: str | Sequence[str] | None = None
|
|
branch_labels: str | Sequence[str] | None = None
|
|
depends_on: str | Sequence[str] | None = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
"""Upgrade schema."""
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table(
|
|
"builds",
|
|
sa.Column("id", sa.UUID(), nullable=False),
|
|
sa.Column("config_hash", sa.String(length=64), nullable=False),
|
|
sa.Column(
|
|
"status",
|
|
sa.Enum(
|
|
"PENDING", "BUILDING", "COMPLETED", "FAILED", "CACHED",
|
|
name="buildstatus",
|
|
),
|
|
nullable=False,
|
|
),
|
|
sa.Column("iso_path", sa.String(length=512), nullable=True),
|
|
sa.Column("error_message", sa.Text(), nullable=True),
|
|
sa.Column("build_log", sa.Text(), nullable=True),
|
|
sa.Column("started_at", sa.DateTime(timezone=True), nullable=True),
|
|
sa.Column("completed_at", sa.DateTime(timezone=True), nullable=True),
|
|
sa.Column(
|
|
"created_at",
|
|
sa.DateTime(timezone=True),
|
|
server_default=sa.text("now()"),
|
|
nullable=False,
|
|
),
|
|
sa.Column(
|
|
"updated_at",
|
|
sa.DateTime(timezone=True),
|
|
server_default=sa.text("now()"),
|
|
nullable=False,
|
|
),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_index(
|
|
op.f("ix_builds_config_hash"), "builds", ["config_hash"], unique=True
|
|
)
|
|
op.create_index("ix_builds_status", "builds", ["status"], unique=False)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
"""Downgrade schema."""
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_index("ix_builds_status", table_name="builds")
|
|
op.drop_index(op.f("ix_builds_config_hash"), table_name="builds")
|
|
op.drop_table("builds")
|
|
# ### end Alembic commands ###
|