"""Add Allowed fields for overrun in License

Revision ID: fa6113ce4306
Revises: 9ed466e9756b
Create Date: 2025-05-08 16:05:55.612416

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'fa6113ce4306'
down_revision = '9ed466e9756b'
branch_labels = None
depends_on = None


def upgrade():
    with op.batch_alter_table('license', schema=None) as batch_op:
        batch_op.add_column(
            sa.Column('additional_storage_allowed', sa.Boolean(), nullable=True))
        batch_op.add_column(
            sa.Column('additional_embedding_allowed', sa.Boolean(), nullable=True))
        batch_op.add_column(
            sa.Column('additional_interaction_allowed', sa.Boolean(), nullable=True))

    op.execute("""
        UPDATE license
        SET additional_storage_allowed = TRUE,
            additional_embedding_allowed = TRUE,
            additional_interaction_allowed = TRUE
    """)

    with op.batch_alter_table('license', schema=None) as batch_op:
        batch_op.alter_column('additional_storage_allowed', nullable=False)
        batch_op.alter_column('additional_embedding_allowed', nullable=False)
        batch_op.alter_column('additional_interaction_allowed', nullable=False)


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

     # ### end Alembic commands ###
