Add per-section TG classifications
This commit is contained in:
38
alembic/versions/0012_message_classifications.py
Normal file
38
alembic/versions/0012_message_classifications.py
Normal file
@@ -0,0 +1,38 @@
|
||||
"""per-section message classifications
|
||||
|
||||
Revision ID: 0012
|
||||
Revises: 0011
|
||||
Create Date: 2026-06-11
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
revision: str = "0012"
|
||||
down_revision: Union[str, None] = "0011"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.create_table(
|
||||
"message_classifications",
|
||||
sa.Column("id", sa.Integer(), primary_key=True),
|
||||
sa.Column("message_id", sa.Integer(), sa.ForeignKey("messages.id", ondelete="CASCADE"), nullable=False),
|
||||
sa.Column("section_id", sa.Integer(), sa.ForeignKey("sections.id", ondelete="CASCADE"), nullable=False),
|
||||
sa.Column("vertical", sa.String(length=32), nullable=False),
|
||||
sa.Column("verdict", postgresql.JSONB(astext_type=sa.Text()), nullable=False),
|
||||
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.func.now()),
|
||||
sa.UniqueConstraint("message_id", "section_id", name="uq_message_classification_section"),
|
||||
)
|
||||
op.create_index("ix_message_classifications_message", "message_classifications", ["message_id"])
|
||||
op.create_index("ix_message_classifications_section", "message_classifications", ["section_id"])
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_index("ix_message_classifications_section", table_name="message_classifications")
|
||||
op.drop_index("ix_message_classifications_message", table_name="message_classifications")
|
||||
op.drop_table("message_classifications")
|
||||
Reference in New Issue
Block a user