"""Moved storage and embedding licensing to Mb iso tokens

Revision ID: 9429f244f1a5
Revises: 48714f1baac5
Create Date: 2024-10-04 08:07:47.976861

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '9429f244f1a5'
down_revision = '48714f1baac5'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('license', schema=None) as batch_op:
        batch_op.add_column(sa.Column('max_storage_mb', sa.Integer(), nullable=False))
        batch_op.add_column(sa.Column('additional_storage_price', sa.Float(), nullable=False))
        batch_op.add_column(sa.Column('included_embedding_mb', sa.Integer(), nullable=False))
        batch_op.add_column(sa.Column('additional_embedding_price', sa.Numeric(precision=10, scale=4), nullable=False))
        batch_op.add_column(sa.Column('overage_embedding', sa.Float(), nullable=False))
        batch_op.add_column(sa.Column('overage_interaction', sa.Float(), nullable=False))
        batch_op.drop_column('additional_storage_token_price')
        batch_op.drop_column('additional_embedding_token_price')
        batch_op.drop_column('max_storage_tokens')
        batch_op.drop_column('allow_overage')
        batch_op.drop_column('included_embedding_tokens')

    with op.batch_alter_table('license_tier', schema=None) as batch_op:
        batch_op.add_column(sa.Column('max_storage_mb', sa.Integer(), nullable=False))
        batch_op.add_column(sa.Column('additional_storage_price_d', sa.Numeric(precision=10, scale=4), nullable=False))
        batch_op.add_column(sa.Column('additional_storage_price_e', sa.Numeric(precision=10, scale=4), nullable=False))
        batch_op.add_column(sa.Column('included_embedding_mb', sa.Integer(), nullable=False))
        batch_op.add_column(sa.Column('additional_embedding_price_d', sa.Numeric(precision=10, scale=4), nullable=False))
        batch_op.add_column(sa.Column('additional_embedding_price_e', sa.Numeric(precision=10, scale=4), nullable=False))
        batch_op.add_column(sa.Column('standard_overage_embedding', sa.Float(), nullable=False))
        batch_op.add_column(sa.Column('standard_overage_interaction', sa.Float(), nullable=False))
        batch_op.drop_column('max_storage_tokens')
        batch_op.drop_column('additional_storage_token_price_e')
        batch_op.drop_column('allow_overage')
        batch_op.drop_column('additional_embedding_token_price_d')
        batch_op.drop_column('included_embedding_tokens')
        batch_op.drop_column('additional_embedding_token_price_e')
        batch_op.drop_column('additional_storage_token_price_d')

    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('license_tier', schema=None) as batch_op:
        batch_op.add_column(sa.Column('additional_storage_token_price_d', sa.NUMERIC(precision=10, scale=4), autoincrement=False, nullable=False))
        batch_op.add_column(sa.Column('additional_embedding_token_price_e', sa.NUMERIC(precision=10, scale=4), autoincrement=False, nullable=False))
        batch_op.add_column(sa.Column('included_embedding_tokens', sa.INTEGER(), autoincrement=False, nullable=False))
        batch_op.add_column(sa.Column('additional_embedding_token_price_d', sa.NUMERIC(precision=10, scale=4), autoincrement=False, nullable=False))
        batch_op.add_column(sa.Column('allow_overage', sa.BOOLEAN(), autoincrement=False, nullable=True))
        batch_op.add_column(sa.Column('additional_storage_token_price_e', sa.NUMERIC(precision=10, scale=4), autoincrement=False, nullable=False))
        batch_op.add_column(sa.Column('max_storage_tokens', sa.INTEGER(), autoincrement=False, nullable=False))
        batch_op.drop_column('standard_overage_interaction')
        batch_op.drop_column('standard_overage_embedding')
        batch_op.drop_column('additional_embedding_price_e')
        batch_op.drop_column('additional_embedding_price_d')
        batch_op.drop_column('included_embedding_mb')
        batch_op.drop_column('additional_storage_price_e')
        batch_op.drop_column('additional_storage_price_d')
        batch_op.drop_column('max_storage_mb')

    with op.batch_alter_table('license', schema=None) as batch_op:
        batch_op.add_column(sa.Column('included_embedding_tokens', sa.INTEGER(), autoincrement=False, nullable=False))
        batch_op.add_column(sa.Column('allow_overage', sa.BOOLEAN(), autoincrement=False, nullable=True))
        batch_op.add_column(sa.Column('max_storage_tokens', sa.INTEGER(), autoincrement=False, nullable=False))
        batch_op.add_column(sa.Column('additional_embedding_token_price', sa.NUMERIC(precision=10, scale=4), autoincrement=False, nullable=False))
        batch_op.add_column(sa.Column('additional_storage_token_price', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=False))
        batch_op.drop_column('overage_interaction')
        batch_op.drop_column('overage_embedding')
        batch_op.drop_column('additional_embedding_price')
        batch_op.drop_column('included_embedding_mb')
        batch_op.drop_column('additional_storage_price')
        batch_op.drop_column('max_storage_mb')

    # ### end Alembic commands ###
