"""monthly predic

Revision ID: 429e1d3f391d
Revises: b7cb14d539d7
Create Date: 2026-01-07 11:02:02.679461

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '429e1d3f391d'
down_revision: Union[str, None] = 'b7cb14d539d7'
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('monthly_forecasts',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('company_id', sa.Integer(), nullable=False),
    sa.Column('location_id', sa.Integer(), nullable=False),
    sa.Column('product_id', sa.Integer(), nullable=False),
    sa.Column('forecast_date', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
    sa.Column('target_month', sa.Date(), nullable=False),
    sa.Column('forecast_qty', sa.Float(), nullable=False),
    sa.Column('model_version', sa.String(), nullable=True),
    sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
    sa.ForeignKeyConstraint(['company_id'], ['companies.company_id'], ),
    sa.ForeignKeyConstraint(['location_id'], ['locations.location_id'], ),
    sa.ForeignKeyConstraint(['product_id'], ['products.product_id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_monthly_forecasts_company_id'), 'monthly_forecasts', ['company_id'], unique=False)
    op.create_index(op.f('ix_monthly_forecasts_id'), 'monthly_forecasts', ['id'], unique=False)
    op.create_index(op.f('ix_monthly_forecasts_location_id'), 'monthly_forecasts', ['location_id'], unique=False)
    op.create_index(op.f('ix_monthly_forecasts_product_id'), 'monthly_forecasts', ['product_id'], unique=False)
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_monthly_forecasts_product_id'), table_name='monthly_forecasts')
    op.drop_index(op.f('ix_monthly_forecasts_location_id'), table_name='monthly_forecasts')
    op.drop_index(op.f('ix_monthly_forecasts_id'), table_name='monthly_forecasts')
    op.drop_index(op.f('ix_monthly_forecasts_company_id'), table_name='monthly_forecasts')
    op.drop_table('monthly_forecasts')
    # ### end Alembic commands ###
