a2c68e2939
- posts: signal, ai_reasoning, prefilter_reason, analysis_version - subscriptions: leverage, position_size_usd, take_profit_pct, stop_loss_pct, min_confidence Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
48 lines
2.2 KiB
Python
48 lines
2.2 KiB
Python
"""Add missing columns to posts and subscriptions
|
|
|
|
Revision ID: 002
|
|
Revises: 001
|
|
Create Date: 2026-04-21 00:00:00.000000
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
revision: str = "002"
|
|
down_revision: Union[str, None] = "001"
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# ── posts: missing columns ────────────────────────────────────────────────
|
|
with op.batch_alter_table("posts") as batch_op:
|
|
batch_op.add_column(sa.Column("signal", sa.String(8), nullable=True))
|
|
batch_op.add_column(sa.Column("ai_reasoning", sa.Text(), nullable=True))
|
|
batch_op.add_column(sa.Column("prefilter_reason", sa.String(32), nullable=True))
|
|
batch_op.add_column(sa.Column("analysis_version", sa.String(16), nullable=True))
|
|
|
|
# ── subscriptions: per-user trading config ────────────────────────────────
|
|
with op.batch_alter_table("subscriptions") as batch_op:
|
|
batch_op.add_column(sa.Column("leverage", sa.Integer(), nullable=False, server_default="3"))
|
|
batch_op.add_column(sa.Column("position_size_usd", sa.Float(), nullable=False, server_default="20.0"))
|
|
batch_op.add_column(sa.Column("take_profit_pct", sa.Float(), nullable=True))
|
|
batch_op.add_column(sa.Column("stop_loss_pct", sa.Float(), nullable=True))
|
|
batch_op.add_column(sa.Column("min_confidence", sa.Integer(), nullable=False, server_default="80"))
|
|
|
|
|
|
def downgrade() -> None:
|
|
with op.batch_alter_table("subscriptions") as batch_op:
|
|
batch_op.drop_column("min_confidence")
|
|
batch_op.drop_column("stop_loss_pct")
|
|
batch_op.drop_column("take_profit_pct")
|
|
batch_op.drop_column("position_size_usd")
|
|
batch_op.drop_column("leverage")
|
|
|
|
with op.batch_alter_table("posts") as batch_op:
|
|
batch_op.drop_column("analysis_version")
|
|
batch_op.drop_column("prefilter_reason")
|
|
batch_op.drop_column("ai_reasoning")
|
|
batch_op.drop_column("signal")
|