"""Added grace period column on MachineType

Revision ID: 88feb1b31a1f
Revises: 2dc275252e0e
Create Date: 2024-02-18 21:20:47.213287

"""

from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = "88feb1b31a1f"
down_revision: Union[str, None] = "2dc275252e0e"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column("machine_types", sa.Column("grace_period_min", sa.Integer(), nullable=True))
    # ### end Alembic commands ###
    op.execute("UPDATE machine_types SET grace_period_min=2 WHERE grace_period_min IS NULL")


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column("machine_types", "grace_period_min")
    # ### end Alembic commands ###
