"""add_entityFile_for_documents

Revision ID: 2c95ef997278
Revises: b750c7bc32f7
Create Date: 2025-07-29 19:28:55.041324

"""
from alembic import op
import sqlalchemy as sa
from app.models.models import get_utc_now


# revision identifiers, used by Alembic.
revision = '2c95ef997278'
down_revision = 'b750c7bc32f7'
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('entity_files',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('entity_type', sa.String(length=50), nullable=False),
    sa.Column('entity_id', sa.Integer(), nullable=False),
    sa.Column('file_name', sa.String(length=255), nullable=False),
    sa.Column('file_path', sa.String(length=500), nullable=False),
    sa.Column('file_type', sa.String(length=100), nullable=False),
    sa.Column('file_size', sa.Integer(), nullable=True),
    sa.Column('description', sa.Text(), nullable=True),
    sa.Column('category', sa.String(length=100), nullable=True),
    sa.Column('uploaded_at', sa.DateTime(), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=False, default=get_utc_now),
    sa.Column('updated_at', sa.DateTime(), nullable=False, default=get_utc_now, onupdate=get_utc_now),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index('idx_category', 'entity_files', ['category'], unique=False)
    op.create_index('idx_created_at', 'entity_files', ['created_at'], unique=False)
    op.create_index('idx_entity_type_id', 'entity_files', ['entity_type', 'entity_id'], unique=False)
    op.create_index('idx_uploaded_at', 'entity_files', ['uploaded_at'], unique=False)
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index('idx_uploaded_at', table_name='entity_files')
    op.drop_index('idx_entity_type_id', table_name='entity_files')
    op.drop_index('idx_created_at', table_name='entity_files')
    op.drop_index('idx_category', table_name='entity_files')
    op.drop_table('entity_files')
    # ### end Alembic commands ###
