"""fix

Revision ID: 69f502262462
Revises: 429e1d3f391d
Create Date: 2026-01-07 11:28:25.227752

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '69f502262462'
down_revision: Union[str, None] = '429e1d3f391d'
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('celery_task_tracker',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('task_id', sa.String(length=255), nullable=False),
    sa.Column('task_name', sa.String(length=255), nullable=False),
    sa.Column('company_id', sa.Integer(), nullable=True),
    sa.Column('status', sa.Enum('PENDING', 'STARTED', 'SUCCESS', 'FAILURE', 'RETRY', 'REVOKED', 'HOLD', name='celerytaskstatus'), nullable=False),
    sa.Column('error_message', sa.String(length=2000), nullable=True),
    sa.Column('started_at', sa.DateTime(timezone=True), nullable=True),
    sa.Column('completed_at', sa.DateTime(timezone=True), nullable=True),
    sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
    sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
    sa.ForeignKeyConstraint(['company_id'], ['companies.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_celery_task_tracker_company_id'), 'celery_task_tracker', ['company_id'], unique=False)
    op.create_index(op.f('ix_celery_task_tracker_id'), 'celery_task_tracker', ['id'], unique=False)
    op.create_index(op.f('ix_celery_task_tracker_task_id'), 'celery_task_tracker', ['task_id'], unique=True)
    op.create_index(op.f('ix_celery_task_tracker_task_name'), 'celery_task_tracker', ['task_name'], unique=False)
    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.id'], ),
    sa.ForeignKeyConstraint(['location_id'], ['locations.id'], ),
    sa.ForeignKeyConstraint(['product_id'], ['products.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')
    op.drop_index(op.f('ix_celery_task_tracker_task_name'), table_name='celery_task_tracker')
    op.drop_index(op.f('ix_celery_task_tracker_task_id'), table_name='celery_task_tracker')
    op.drop_index(op.f('ix_celery_task_tracker_id'), table_name='celery_task_tracker')
    op.drop_index(op.f('ix_celery_task_tracker_company_id'), table_name='celery_task_tracker')
    op.drop_table('celery_task_tracker')
    # ### end Alembic commands ###
