"""replace License End Date with Nr of Periods

Revision ID: ef0aaf00f26d
Revises: 638c4718005d
Create Date: 2025-05-14 04:04:54.535439

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'ef0aaf00f26d'
down_revision = '638c4718005d'
branch_labels = None
depends_on = None


def upgrade():
    with op.batch_alter_table('license', schema=None) as batch_op:
        # Add column with server default for existing rows
        batch_op.add_column(sa.Column('nr_of_periods', sa.Integer(), nullable=False, server_default='12'))
        batch_op.drop_column('end_date')

    # Remove the server default after creation (optional)
    with op.batch_alter_table('license', schema=None) as batch_op:
        batch_op.alter_column('nr_of_periods', server_default=None)


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    pass
    # ### end Alembic commands ###
