GeoIntel release gates / Compile, test, contracts and builds (push) Successful in 1m49s
GeoIntel release gates / Python and npm vulnerability policy (push) Successful in 21s
GeoIntel release gates / Production AI image, SBOM and container scan (push) Successful in 5m39s
GeoIntel release gates / Deploy exact gated revision to Unraid (push) Failing after 58m43s
65 lines
3.4 KiB
Python
65 lines
3.4 KiB
Python
"""Add durable operator review decisions for detection QA evidence."""
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
from sqlalchemy.dialects import postgresql
|
|
|
|
|
|
revision = "202607150001"
|
|
down_revision = "202607140001"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.create_table(
|
|
"detection_reviews",
|
|
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
|
|
sa.Column("project_id", postgresql.UUID(as_uuid=True), nullable=False),
|
|
sa.Column("quality_check_id", postgresql.UUID(as_uuid=True), nullable=False),
|
|
sa.Column("analysis_run_id", postgresql.UUID(as_uuid=True), nullable=True),
|
|
sa.Column("evidence_role", sa.String(length=32), nullable=False),
|
|
sa.Column("evidence_feature_id", sa.String(length=255), nullable=False),
|
|
sa.Column("detection_id", postgresql.UUID(as_uuid=True), nullable=True),
|
|
sa.Column("reference_feature_id", postgresql.UUID(as_uuid=True), nullable=True),
|
|
sa.Column("decision", sa.String(length=64), server_default="unreviewed", nullable=False),
|
|
sa.Column("notes", sa.Text(), nullable=True),
|
|
sa.Column("reviewed_by", sa.String(length=120), server_default="operator", nullable=False),
|
|
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.CheckConstraint(
|
|
"evidence_role IN ('false_positive', 'false_negative')",
|
|
name="ck_detection_reviews_evidence_role",
|
|
),
|
|
sa.CheckConstraint(
|
|
"decision IN ('confirmed_model_false_positive', 'confirmed_model_false_negative', "
|
|
"'reference_gap_or_change', 'qa_alignment_mismatch', "
|
|
"'imagery_obscured_or_uncertain', 'uncertain', 'unreviewed')",
|
|
name="ck_detection_reviews_decision",
|
|
),
|
|
sa.ForeignKeyConstraint(["analysis_run_id"], ["analysis_runs.id"], ondelete="SET NULL"),
|
|
sa.ForeignKeyConstraint(["detection_id"], ["detections.id"], ondelete="SET NULL"),
|
|
sa.ForeignKeyConstraint(["project_id"], ["projects.id"], ondelete="CASCADE"),
|
|
sa.ForeignKeyConstraint(["quality_check_id"], ["quality_checks.id"], ondelete="CASCADE"),
|
|
sa.ForeignKeyConstraint(["reference_feature_id"], ["vector_features.id"], ondelete="SET NULL"),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
sa.UniqueConstraint(
|
|
"quality_check_id",
|
|
"evidence_role",
|
|
"evidence_feature_id",
|
|
name="uq_detection_reviews_evidence",
|
|
),
|
|
)
|
|
op.create_index("ix_detection_reviews_project_id", "detection_reviews", ["project_id"])
|
|
op.create_index("ix_detection_reviews_quality_check_id", "detection_reviews", ["quality_check_id"])
|
|
op.create_index("ix_detection_reviews_analysis_run_id", "detection_reviews", ["analysis_run_id"])
|
|
op.create_index("ix_detection_reviews_decision", "detection_reviews", ["decision"])
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index("ix_detection_reviews_decision", table_name="detection_reviews")
|
|
op.drop_index("ix_detection_reviews_analysis_run_id", table_name="detection_reviews")
|
|
op.drop_index("ix_detection_reviews_quality_check_id", table_name="detection_reviews")
|
|
op.drop_index("ix_detection_reviews_project_id", table_name="detection_reviews")
|
|
op.drop_table("detection_reviews")
|