"""LicenseUsage and Tenant updates

Revision ID: 8fdd7f2965c1
Revises: 6a7743d08106
Create Date: 2024-10-08 06:33:50.297396

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '8fdd7f2965c1'
down_revision = '6a7743d08106'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('business_event_log', schema=None) as batch_op:
        batch_op.add_column(sa.Column('document_version_file_size', sa.Float(), nullable=True))

    with op.batch_alter_table('license_usage', schema=None) as batch_op:
        batch_op.add_column(sa.Column('embedding_prompt_tokens_used', sa.Integer(), nullable=True))
        batch_op.add_column(sa.Column('embedding_completion_tokens_used', sa.Integer(), nullable=True))
        batch_op.add_column(sa.Column('embedding_total_tokens_used', sa.Integer(), nullable=True))
        batch_op.add_column(sa.Column('interaction_prompt_tokens_used', sa.Integer(), nullable=True))
        batch_op.add_column(sa.Column('interaction_completion_tokens_used', sa.Integer(), nullable=True))
        batch_op.add_column(sa.Column('interaction_total_tokens_used', sa.Integer(), nullable=True))
        batch_op.drop_column('interaction_tokens_used')

    with op.batch_alter_table('tenant', schema=None) as batch_op:
        batch_op.add_column(sa.Column('storage_dirty', sa.Boolean(), nullable=True))

    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('tenant', schema=None) as batch_op:
        batch_op.drop_column('storage_dirty')

    with op.batch_alter_table('license_usage', schema=None) as batch_op:
        batch_op.add_column(sa.Column('interaction_tokens_used', sa.INTEGER(), autoincrement=False, nullable=True))
        batch_op.drop_column('interaction_total_tokens_used')
        batch_op.drop_column('interaction_completion_tokens_used')
        batch_op.drop_column('interaction_prompt_tokens_used')
        batch_op.drop_column('embedding_total_tokens_used')
        batch_op.drop_column('embedding_completion_tokens_used')
        batch_op.drop_column('embedding_prompt_tokens_used')

    with op.batch_alter_table('business_event_log', schema=None) as batch_op:
        batch_op.drop_column('document_version_file_size')

    # ### end Alembic commands ###
