43 lines
1.5 KiB
Python
43 lines
1.5 KiB
Python
"""add fundamentals table
|
|
|
|
Revision ID: b2c3d4e5f6a7
|
|
Revises: a1b2c3d4e5f6
|
|
Create Date: 2026-02-23 10:00:00.000000
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
from sqlalchemy.dialects import postgresql
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = "b2c3d4e5f6a7"
|
|
down_revision: Union[str, Sequence[str], None] = "a1b2c3d4e5f6"
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
"""Create the fundamentals table for caching fundamental data."""
|
|
|
|
op.create_table(
|
|
"fundamentals",
|
|
sa.Column("id", postgresql.UUID(as_uuid=True), primary_key=True),
|
|
sa.Column("ticker", sa.String(20), unique=True, nullable=False, index=True),
|
|
sa.Column("eps_ttm", sa.Float, nullable=True),
|
|
sa.Column("pe_ratio", sa.Float, nullable=True),
|
|
sa.Column("peg_ratio", sa.Float, nullable=True),
|
|
sa.Column("revenue_growth_yoy", sa.Float, nullable=True),
|
|
sa.Column("profit_margin", sa.Float, nullable=True),
|
|
sa.Column("debt_to_equity", sa.Float, nullable=True),
|
|
sa.Column("market_cap", sa.Float, nullable=True),
|
|
sa.Column("fetched_at", sa.DateTime(timezone=True), nullable=False),
|
|
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.func.now()),
|
|
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.func.now()),
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
"""Drop the fundamentals table."""
|
|
op.drop_table("fundamentals")
|