"""Add market_prices table for price caching Revision ID: 003_market_prices Revises: 002_add_positions Create Date: 2026-01-20 16:00:00.000000 """ from alembic import op import sqlalchemy as sa from datetime import datetime # revision identifiers, used by Alembic. revision = '003_market_prices' down_revision = '002_add_positions' branch_labels = None depends_on = None def upgrade() -> None: # Create market_prices table op.create_table( 'market_prices', sa.Column('id', sa.Integer(), nullable=False), sa.Column('symbol', sa.String(length=20), nullable=False), sa.Column('price', sa.Numeric(precision=20, scale=6), nullable=False), sa.Column('fetched_at', sa.DateTime(), nullable=False, default=datetime.utcnow), sa.Column('source', sa.String(length=50), default='yahoo_finance'), sa.PrimaryKeyConstraint('id') ) # Create indexes op.create_index('idx_market_prices_symbol', 'market_prices', ['symbol'], unique=True) op.create_index('idx_symbol_fetched', 'market_prices', ['symbol', 'fetched_at']) def downgrade() -> None: op.drop_index('idx_symbol_fetched', table_name='market_prices') op.drop_index('idx_market_prices_symbol', table_name='market_prices') op.drop_table('market_prices')