"""add_portfolio_model

Revision ID: c63cb9ba06b2
Revises: dfe454fc4858
Create Date: 2024-11-25 23:20:40.706753

"""

from typing import Sequence
from typing import Union

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision: str = "c63cb9ba06b2"
down_revision: Union[str, None] = "dfe454fc4858"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "xarizmi_portfolio_item",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("symbol_id", sa.Integer(), nullable=False),
        sa.Column("market_value", sa.Float(), nullable=False),
        sa.Column("quantity", sa.Float(), nullable=False),
        sa.Column("datetime", sa.DateTime(), nullable=False),
        sa.ForeignKeyConstraint(
            ["symbol_id"],
            ["xarizmi_symbol.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint(
            "symbol_id", "datetime", name="uix_symbol_datetime"
        ),
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table("xarizmi_portfolio_item")
    # ### end Alembic commands ###
