"""initial

Revision ID: 65a818bbc5d9
Revises: 
Create Date: 2025-12-15 13:36:16.145864

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '65a818bbc5d9'
down_revision: Union[str, Sequence[str], None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('products',
    sa.Column('id', sa.String(length=36), nullable=False),
    sa.Column('sku', sa.String(length=255), nullable=False),
    sa.Column('name', sa.String(length=255), nullable=False),
    sa.Column('brand_name', sa.String(length=255), nullable=True),
    sa.Column('supplier_name', sa.String(length=255), nullable=True),
    sa.Column('barcode', sa.String(length=255), nullable=True),
    sa.Column('markup_percent', sa.Float(), nullable=True),
    sa.Column('quantity_on_hand', sa.Integer(), nullable=False),
    sa.Column('reorder_level', sa.Integer(), nullable=False),
    sa.Column('product_type', sa.Enum('MEDICAL', 'NON_MEDICAL', name='producttype'), nullable=False),
    sa.Column('dispense_without_prescription', sa.Boolean(), nullable=False),
    sa.Column('return_policy', sa.String(length=255), nullable=True),
    sa.Column('status', sa.Enum('ACTIVE', 'PENDING', 'INACTIVE', name='productstatus'), nullable=False),
    sa.Column('created_at', sa.DateTime(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False),
    sa.Column('updated_at', sa.DateTime(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_products_barcode'), 'products', ['barcode'], unique=False)
    op.create_index(op.f('ix_products_name'), 'products', ['name'], unique=False)
    op.create_index(op.f('ix_products_sku'), 'products', ['sku'], unique=True)
    op.create_table('stock_adjustments',
    sa.Column('id', sa.String(length=36), nullable=False),
    sa.Column('product_id', sa.String(length=36), nullable=False),
    sa.Column('change_qty', sa.Integer(), nullable=False),
    sa.Column('reason', sa.Enum('INITIAL_IMPORT', 'MANUAL_ADJUSTMENT', name='stockadjustmentreason'), nullable=False),
    sa.Column('reference', sa.String(length=255), nullable=True),
    sa.Column('note', sa.String(length=255), nullable=True),
    sa.Column('created_by_user_id', sa.String(length=36), nullable=True),
    sa.Column('created_at', sa.DateTime(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False),
    sa.ForeignKeyConstraint(['product_id'], ['products.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_stock_adjustments_product_id'), 'stock_adjustments', ['product_id'], unique=False)
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_stock_adjustments_product_id'), table_name='stock_adjustments')
    op.drop_table('stock_adjustments')
    op.drop_index(op.f('ix_products_sku'), table_name='products')
    op.drop_index(op.f('ix_products_name'), table_name='products')
    op.drop_index(op.f('ix_products_barcode'), table_name='products')
    op.drop_table('products')
    # ### end Alembic commands ###
