"""add_scoring_config

Single-row table to persist scoring weights in the database,
replacing the mutable in-process Settings approach.

Revision ID: b027scorecfg
Revises: b026techidx
Create Date: 2026-02-19 10:00:00.000000

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

revision: str = "b027scorecfg"
down_revision: Union[str, None] = "b026techidx"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.create_table(
        "scoring_config",
        sa.Column("id", postgresql.UUID(as_uuid=True), primary_key=True),
        sa.Column("weight_tests", sa.Float(), nullable=False, server_default="40.0"),
        sa.Column("weight_detection_rules", sa.Float(), nullable=False, server_default="20.0"),
        sa.Column("weight_d3fend", sa.Float(), nullable=False, server_default="15.0"),
        sa.Column("weight_freshness", sa.Float(), nullable=False, server_default="15.0"),
        sa.Column("weight_platform_diversity", sa.Float(), nullable=False, server_default="10.0"),
        sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.func.now()),
    )


def downgrade() -> None:
    op.drop_table("scoring_config")
