FastAPI + Celery + Next.js + Postgres/Redis app with company monitoring, source collection, LLM-based change analysis, enrichment, and account security (Turnstile, escalating lockout, email verification).
69 lines
2.4 KiB
Python
69 lines
2.4 KiB
Python
"""create reports
|
|
|
|
Revision ID: c06c845cdd10
|
|
Revises: cb61ba9570fb
|
|
Create Date: 2026-07-31 19:52:22.947563
|
|
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from collections.abc import Sequence
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
revision: str = "c06c845cdd10"
|
|
down_revision: str | None = "cb61ba9570fb"
|
|
branch_labels: Sequence[str] | str | None = None
|
|
depends_on: Sequence[str] | str | None = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table(
|
|
"reports",
|
|
sa.Column("company_id", sa.Uuid(), nullable=False),
|
|
sa.Column("monitoring_run_id", sa.Uuid(), nullable=True),
|
|
sa.Column(
|
|
"report_type",
|
|
sa.Enum(
|
|
"BASELINE",
|
|
"UPDATE",
|
|
"MONTHLY",
|
|
"MANUAL",
|
|
name="reporttype",
|
|
native_enum=False,
|
|
length=20,
|
|
),
|
|
nullable=False,
|
|
),
|
|
sa.Column("title", sa.String(length=300), nullable=False),
|
|
sa.Column("executive_summary", sa.Text(), nullable=False),
|
|
sa.Column("structured_report", sa.JSON(), nullable=False),
|
|
sa.Column("markdown_content", sa.Text(), nullable=False),
|
|
sa.Column("model_provider", sa.String(length=50), nullable=False),
|
|
sa.Column("model_name", sa.String(length=100), nullable=False),
|
|
sa.Column("prompt_version", sa.String(length=20), nullable=False),
|
|
sa.Column("id", sa.Uuid(), nullable=False),
|
|
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
|
|
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=False),
|
|
sa.ForeignKeyConstraint(["company_id"], ["companies.id"], ondelete="CASCADE"),
|
|
sa.ForeignKeyConstraint(["monitoring_run_id"], ["monitoring_runs.id"], ondelete="SET NULL"),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
sa.UniqueConstraint("id"),
|
|
)
|
|
op.create_index(op.f("ix_reports_company_id"), "reports", ["company_id"], unique=False)
|
|
op.create_index(
|
|
op.f("ix_reports_monitoring_run_id"), "reports", ["monitoring_run_id"], unique=False
|
|
)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_index(op.f("ix_reports_monitoring_run_id"), table_name="reports")
|
|
op.drop_index(op.f("ix_reports_company_id"), table_name="reports")
|
|
op.drop_table("reports")
|
|
# ### end Alembic commands ###
|